Dnsmasq is currently compiled with round – robin algorithm (or a simple implementation of this algorithm). We make use of this capability for an very simple load balancing technique.
What dnsmasq & round robin do? Basically , we configure 1 host and give for him N° IP addresses , dnsmasq changes the IP order of this IP corresponding to one host after any single DNS request.
Whats the point?
After each new connection the IP responding will be the next in the list , doing so the requests will be balanced on 3 different servers managing 1 domain.
Let’s say we have a very big host called blackbox and for not bombing our host and the load we just add 3-5 or N servers for balancing the load of the server.
We give to our linux router/firewall an configuration like:
# /etc/hosts: static lookup table for host names
#<ip-address> <hostname.domain.org> <hostname>
127.0.0.1 localhost.localdomain localhost darkinet
#NOTE: In real life this should be something like blackbox.com with an public IP address.
#192.168.1.200 www.google.com #I added google before lol 😀
# End of file
Ok, this is good, now lets see our simple configuration at work:
If we just $dig blackbox
;; ANSWER SECTION: blackbox. 0 IN A 192.168.0.150 blackbox. 0 IN A 192.168.0.151 blackbox. 0 IN A 192.168.0.152
The seccond response
;; ANSWER SECTION: blackbox. 0 IN A 192.168.0.151 blackbox. 0 IN A 192.168.0.152 blackbox. 0 IN A 192.168.0.150
The third response
;; ANSWER SECTION: blackbox. 0 IN A 192.168.0.152 blackbox. 0 IN A 192.168.0.150 blackbox. 0 IN A 192.168.0.151
So, we see that the order of the IP changes after each DNS request cyclically.
Then we restart dnsmasq
# /etc/init.d/dnsmasq restart
This is not for serious load balancing (yep it costs up to 4000 bucks or even more)
So in conclusion, if you are not
;; ADDITIONAL SECTION: ns1.google.com. 329163 IN A 184.108.40.206 ns2.google.com. 327587 IN A 220.127.116.11 ns3.google.com. 331744 IN A 18.104.22.168 ns4.google.com. 331744 IN A 22.214.171.124
And you don’t have the need to use 4 server farms for a domain, than this may be your case.