How do I setup round robin DNS?

Round robin DNS is a technique in which load balancing is performed by a DNS server instead of a strictly dedicated machine. A DNS record has more than one value IP address.

ADVERTISEMENTS

When a request is made to the DNS server which serves this record, the answer it gives alternates for each request. For instance, if you had a three webserver that you wished to distribute requests between, you could setup your DNS zone as follows:

Open your zone file using vi text editor and add/modify www entry as follows:
# vi zone.cyberciti.biz
Append/modfiy www entry:

www   IN   A   68.142.234.44
          IN   A   68.142.234.45
          IN   A   68.142.234.46
         IN   A   68.142.234.47

Save and restart BIND9. If you run nslookup for cyberciti.biz:

# nslookup cyberciti.biz

Output:

Address: 68.142.234.47
Name:   cyberciti.biz
Address: 68.142.234.44
Name:   cyberciti.biz
Address: 68.142.234.45
Name:   cyberciti.biz
Address: 68.142.234.46

One more time:
# nslookup cyberciti.biz
Output:

Name:   cyberciti.biz
Address: 68.142.234.46
Name:   cyberciti.biz
Address: 68.142.234.45
Name:   cyberciti.biz
Address: 68.142.234.44
Name:   cyberciti.biz
Address: 68.142.234.47

When a query is made to the DNS server it will first give the IP of 68.142.234.44 for the www host. The next time a request is made for the IP of www, it will serve 68.142.234.45 and so on.

The order in which IP addresses from the list are returned is the basis of the round robin name. While this is a form of load balancing, it should be noted that if one of the hosts becomes unavailable, the DNS server does not know this, and will still continue to give out the IP of the downed server.

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
5 comments… add one
  • rrdns Apr 9, 2009 @ 9:30

    Yep, Round Robin DNS plays a crutial role in the managing the load between the multiple servers. Besides this the Round Robin DNS is also used for the services like mails,ftp and even IIRC. Being a service providers which offers clusters and high hosting setups we had setup a clustered for handling their mails for one of the corporate website having heavy mailing activity for one of our customer.

    • Pirk May 16, 2015 @ 16:12

      thanks worked like a champ !!!

  • jalal hajigholamali Aug 17, 2011 @ 15:58

    thanks, very useful

  • Mark Jun 2, 2014 @ 0:56

    Hi. If I have 2 file servers then the zone file that I will be editing is the zone file of the DNS server right?

    Thanks.

    • Ashish Kumar Laxkar Aug 31, 2016 @ 0:22

      Yes, you need to make changes in zone file of DNS server..

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.