Round-Robin DNS Setup

updated: 12/21/2022

Round-Robin DNS Setup is a great way to ensure your website or online application runs smoothly and efficiently. It provides an effective load-balancing technique that improves the performance of your website by distributing incoming requests across multiple sources.

This setup helps to reduce downtime, as well as eliminate single points of failure. Through the strategic use of multiple IP addresses and Domain Name System (DNS) records, Round-Robin DNS setups help provide a reliable and stable experience for your users.


 

Round-Robin DNS Setup

Round-robin DNS provides load distribution across multiple machines using the same hostname but each having its own IP.  Each request to the DNS server is routed to a different machine in sequential order. 
Configuration of round-robin DNS uses the Berkeley Internet Name Domain(BIND) named daemon.  BIND uses zone files to define hostnames with address records.
 
An example of a round-robin BIND zone file:
 
 nfs.test.local IN A 10.10.0.101
 nfs.test.local IN A 10.10.0.102
 nfs.test.local IN A 10.10.0.103
 

Install and Setup

This applies to RHEL.
Make sure the BIND package is installed.   Do not install the bind-chroot package:
 
 yum install bind
 
The install creates the named service and the following configuration files:
 
/etc/named.conf                          #read when named service starts
/var/named                                  #working directory for the named service
/var/named/dynamic                   #directory for the zone data
 
Edit named.conf to look like the following:
 
//
//   /etc/named.conf
//
options {
         listen-on port 53 { any; };
         directory “/var/named/”;                 # states working directory
         allow-query { any; };                     # lists which hosts can query the nameserver
         recursion yes;
         forwarders { x.x.x.x; x.x.x.x; };    # site dns servers
};
 
logging {
         channel default_debug {
                 file “data/named.run”;
                 severity dynamic;
         };
};
 
//
// Zone Definitions
//
zone “localhost” IN {
         type master;
         file “named.localhost”;
};
 
 zone “test.local” IN {
         allow-transfer { any; };
         file “dynamic/nfstest.main”;                     # zone configuration file
         type master;                                                 # indicates it’s the owner of zone file
};
 
Edit the zone file to look like the following, adding you own hostname to IP mappings:
 
//
//  /var/named/dynamic/nfstest.main
//
//
 
$TTL 1d                            # how long a zone record is valid
$ORIGIN test.local.         # allows you to append the domain name to unqualified records
@       IN SOA          s01.test. root (              #Start of Authority record
                         20120527       ;serial
                         4H             ;refresh
                         1H             ;retry
                         1W             ;expiry
                         1D )           ;minimum
;
        IN NS           s01.test.local.                 # states the nameserver
;       IN NS           secondary.test.local.
;
;********************************
;*   Domain Address Information *
;********************************
;
; Local Host
;
localhost       IN      A       127.0.0.1
;
; Machine Names
;
; Private  Network (10.10.0.0/24)
;
;
n01             IN      A       10.10.0.01
n02             IN      A       10.10.0.02
n03             IN      A       10.10.0.03
n04             IN      A       10.10.0.04
n05             IN      A       10.10.0.05
n06             IN      A       10.10.0.06
n07             IN      A       10.10.0.07
n08             IN      A       10.10.0.08
n09             IN      A       10.10.0.09
n10             IN      A       10.10.0.10
;
 
fs01            IN      A       10.10.0.21
fs02            IN      A       10.10.0.22
s01            IN      A       10.10.0.23
;
; Clustered NFS                                      # this is the round robin entry
nfs             IN      A       10.10.0.101
nfs             IN      A       10.10.0.102
nfs             IN      A       10.10.0.103
Start the named service:
 
service named start
chkconfig named on
 
Configure the clients to point to the DNS nameserver:
 
root@client# vi /etc/resolv.conf
 
 search nfs.test.local
 nameserver 10.10.0.23                       # add your nameserver IP
 nameserver x.x.x.x                           # add site nameserver
 
Now whenever a client machine queries the name ‘nfs’  the response from the DNS server will rotate through the entries above.