DNS Load-Balancing with HAPROXY

debian-jessiedomain-name-systemhaproxyload balancing

I have a net with 2 DNS servers (master & slave), but I don't want clients to ask directly to them. So, in the same net, I have a debian machine with haproxy 1.7.5 installed. I want clients to have in their /etc/resolv.conf file the IP of the proxy. I want the proxy to balance the load between the two servers.

IP DNS master = 10.10.24.2
IP DNS slave  = 10.10.24.4
IP PROXY      = 10.10.24.5

In the file /etc/haproxy/haproxy.cfg at the end, I added:

resolvers mydns
    nameservers dns1 10.10.24.2:53
    nameservers dns2 10.10.24.4:53

Then I start haproxy:

haproxy -f /etc/haproxy/haproxy.cfg

If I execute in the proxy:

netstat -tuna

I get these two new lines:

udp    0    0    10.10.24.5:35000    10.10.24.2:53    ESTABLISHED
udp    0    0    10.10.24.5:35000    10.10.24.4:53    ESTABLISHED

But I was expecting to receive something like this:

udp    0    0    10.10.24.5:53    10.10.24.2:53    ESTABLISHED
udp    0    0    10.10.24.5:53    10.10.24.4:53    ESTABLISHED

Obviously, the DNS requests from clients to the proxy aren't working…

Is it possible to achieve this using haproxy?

Best Answer

You don't need to load balance your DNS servers. It is enough to have two DNS servers configured on the client side and that's it.

If you don't have another machine acting as a load balancer, you will be creating a single point of failure for DNS service.

This is a similar post at serverfault.

Related Topic