What's new

dnsmasq - Round Robin (load balancing) client IP for A record resolution

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

mvadu

Regular Contributor
hello, I have a docker swarm cluster running few things. I use Traefik as ingress controller. But currently I have only one node running it, I want to add a second node for HA purposes. Question is how do I make dnsmasq to resond with one of the two IP addresses for same DNS request?

Note that I use adguardhome entware package which front ends all client DNS requests, and forwards to dnsmasq on the same router.
I have static IPs for the two servers running Traefik
server1 - 192.168.23.23
server2 - 192.168.23.32


I can access the services individually now by modifying the A record for `traefik.local` to point to either of the two. I want it to load balance between the two.
 
That is already the default behaviour of dnsmasq unless you have specified --no-round-robin (if your version of dnsmasq supports it).

Code:
C:\>nslookup test
Server:  RT-AX86U.home.lan
Address:  192.168.1.1

Name:    test.home.lan
Addresses:  192.168.1.100
          192.168.1.101


C:\>nslookup test
Server:  RT-AX86U.home.lan
Address:  192.168.1.1

Name:    test.home.lan
Addresses:  192.168.1.101
          192.168.1.100


C:\>nslookup test
Server:  RT-AX86U.home.lan
Address:  192.168.1.1

Name:    test.home.lan
Addresses:  192.168.1.100
          192.168.1.101


C:\>nslookup test
Server:  RT-AX86U.home.lan
Address:  192.168.1.1

Name:    test.home.lan
Addresses:  192.168.1.101
          192.168.1.100


C:\>nslookup test
Server:  RT-AX86U.home.lan
Address:  192.168.1.1

Name:    test.home.lan
Addresses:  192.168.1.100
          192.168.1.101


C:\>nslookup test
Server:  RT-AX86U.home.lan
Address:  192.168.1.1

Name:    test.home.lan
Addresses:  192.168.1.101
          192.168.1.100


C:\>nslookup test
Server:  RT-AX86U.home.lan
Address:  192.168.1.1

Name:    test.home.lan
Addresses:  192.168.1.100
          192.168.1.101


C:\>nslookup test
Server:  RT-AX86U.home.lan
Address:  192.168.1.1

Name:    test.home.lan
Addresses:  192.168.1.101
          192.168.1.100


C:\>nslookup test
Server:  RT-AX86U.home.lan
Address:  192.168.1.1

Name:    test.home.lan
Addresses:  192.168.1.100
          192.168.1.101


C:\>nslookup test
Server:  RT-AX86U.home.lan
Address:  192.168.1.1

Name:    test.home.lan
Addresses:  192.168.1.101
          192.168.1.100


C:\>nslookup test
Server:  RT-AX86U.home.lan
Address:  192.168.1.1

Name:    test.home.lan
Addresses:  192.168.1.100
          192.168.1.101


C:\>nslookup test
Server:  RT-AX86U.home.lan
Address:  192.168.1.1

Name:    test.home.lan
Addresses:  192.168.1.101
          192.168.1.100


C:\>nslookup test
Server:  RT-AX86U.home.lan
Address:  192.168.1.1

Name:    test.home.lan
Addresses:  192.168.1.100
          192.168.1.101


C:\>nslookup test
Server:  RT-AX86U.home.lan
Address:  192.168.1.1

Name:    test.home.lan
Addresses:  192.168.1.101
          192.168.1.100


C:\>nslookup test
Server:  RT-AX86U.home.lan
Address:  192.168.1.1

Name:    test.home.lan
Addresses:  192.168.1.100
          192.168.1.101


C:\>nslookup test
Server:  RT-AX86U.home.lan
Address:  192.168.1.1

Name:    test.home.lan
Addresses:  192.168.1.101
          192.168.1.100


C:\>nslookup test
Server:  RT-AX86U.home.lan
Address:  192.168.1.1

Name:    test.home.lan
Addresses:  192.168.1.100
          192.168.1.101
 
Last edited:
Thank you for that info @ColinTaylor how do you define that A record via the UI? did you manually add it for test.home.lan?
For that test I just added the two entries to the hosts file in /etc and manually restarted dnsmasq. You can achieve the same result through the GUI by creating two entries with different MAC addresses but the same hostname.

Untitled.png
 
thank you!! i think you gave me a complete answer I was looking for. I will have to use the /etc/hosts route since I want to keep the server1/2 as host names for other purposes, the entry in the hosts will be a new name with two IPs.
 

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top