Search code examples
nginxdnsstreamload-balancingcentos7

CentOS 7 - NGINX - DNS Load Balance


Working on building a DNS Load Balance service on CentOS 7 using NGINX. Had this working on Ubuntu but started getting spotty results and wanted to move to centos. Problem I am running into is something has port 53 tied up and I can't seem to figure out what. This makes sense because Ubuntu has the same problem but easy fix. Just turn off the service that is running holding port 53. I've been digging and googling my bum off but can't seem to find the smoking gun.

What service is holding port 53 by default on CentOS?

Any help is much appreciated. Thank you.

● nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/nginx.service.d
           └─nginx.conf
   Active: failed (Result: exit-code) since Wed 2019-12-18 16:11:02 EST; 13min ago
  Process: 1863 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=1/FAILURE)
  Process: 1861 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)

Dec 18 16:11:02 dnsload.dutil.com systemd[1]: Starting The nginx HTTP and reverse proxy server...
Dec 18 16:11:02 dnsload.dutil.com nginx[1863]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Dec 18 16:11:02 dnsload.dutil.com nginx[1863]: nginx: [emerg] bind() to 0.0.0.0:53 failed (13: Permission denied)
Dec 18 16:11:02 dnsload.dutil.com nginx[1863]: nginx: configuration file /etc/nginx/nginx.conf test failed
Dec 18 16:11:02 dnsload.dutil.com systemd[1]: nginx.service: Control process exited, code=exited status=1
Dec 18 16:11:02 dnsload.dutil.com systemd[1]: nginx.service: Failed with result 'exit-code'.
Dec 18 16:11:02 dnsload.dutil.com systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
stream {
    upstream dns_servers {
        least_conn;
        zone dns_mem 64k;
        server 192.168.100.240:53 fail_timeout=60s;
        server 192.168.100.241:53 fail_timeout=60s;
        server 192.168.100.239:53 fail_timeout=60s;
    }

    server {
        listen 53  udp;
        listen 53; #tcp
        proxy_pass      dns_servers;
        error_log       /var/log/nginx/dns.log debug;
        proxy_responses 1;
        proxy_timeout   1s;
    }
}

Solution

  • PowerDNS DNSDIST https://dnsdist.org/

    Found this to be an AMAZING! solution to dns load balancing!