Home > DNS > Ubuntu 10.10 Bind Round Robin HowTo

Ubuntu 10.10 Bind Round Robin HowTo

Hi everyone,

In this post i will explain the steps to configure bind to perform dns queries in a round robin fashion(everything works from your local machine).

Step1) Install bind and bind-utils

root@heuristics:~# sudo apt-get install bind9 bind9utils

By default all the configuration files will be present in the location “/etc/bind”.

Step 2) Add additional IP addresses to your local machine and restart the networking service.  Before modifying the network configuration, take a backup(Press Ctrl+D to save).  After restart view the new ip’s added using “ifconfig” command.

root@heuristics:~# cp -p /etc/network/interfaces /etc/network/interfaces.original-`date +%F`

root@heuristics:~# cat > /etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.1.3
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

auto eth0:1
iface eth0:1 inet static
address 192.168.1.4
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

auto eth0:2
iface eth0:2 inet static
address 192.168.1.5
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

auto eth0:3
iface eth0:3 inet static
address 192.168.1.6
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

auto eth0:4
iface eth0:4 inet static
address 192.168.1.7
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

auto eth0:5
iface eth0:5 inet static
address 192.168.1.8
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
root@heuristics:~# /etc/init.d/networking restart

root@heuristics:~# ifconfig -a

Step 3) Add the following zone in “/etc/bind/named.conf.local”

zone “mercy.com” {
type master;
file “/var/cache/bind/mercy.com.db”;
};

Step 4) Create a zone file for domain “mercy.com” and add the contents listed below( Press Ctrl+D to exit).

root@heuristics:~# grep directory /etc/bind/named.conf.options
directory “/var/cache/bind”;
root@heuristics:~# cat > /var/cache/bind/mercy.com.db

$TTL 60    ; default TTL for zone
$ORIGIN mercy.com.
@             IN      SOA   ns1.mercy.com. jackal.mercy.com. (
2003080800 ; se = serial number
10        ; ref = refresh
10        ; ret = update retry
10         ; ex = expiry
10         ; min = minimum
)

IN      A       192.168.1.3
IN      A       192.168.1.4
IN      A       192.168.1.5
IN      A       192.168.1.6
IN      A       192.168.1.7
IN      A       192.168.1.8
IN      NS      ns1.mercy.com.
IN      MX  10  mail.mercy.com.
ns1 IN      A       192.168.1.3
mail IN      A       192.168.1.3
root@heuristics:~#

Step 5) Specify the rrset-order in the bind configuration(inside options directive).

root@heuristics:~# cat /etc/bind/named.conf.options
options {
directory “/var/cache/bind”;
auth-nxdomain no;    # conform to RFC1035
listen-on-v6 { any; };
rrset-order {order cyclic;};
};

root@heuristics:~#

Step 6) Add the local name server IP in “/etc/resolv.conf”. In my case the nameserver is running from localhost and the IP 192.168.1.3 .

root@heuristics:~# cat /etc/resolv.conf
nameserver 127.0.0.1
nameserver 192.168.1.3
nameserver 192.168.1.1
root@heuristics:~#

Step 7) Make sure that the dns lookup order configured in “/etc/nsswitch.conf” is as pasted below,

root@heuristics:~# grep hosts /etc/nsswitch.conf
hosts:          files dns mdns4_minimal [NOTFOUND=return] mdns4
root@heuristics:~#

Step 8) Restart the bind service and test the working of bind round robin scheduling.

root@heuristics:~# service bind9 restart
* Stopping domain name service… bind9                                                                              [ OK ]
* Starting domain name service… bind9                                                                              [ OK ]
root@heuristics:~# for((i=1;i<=10;i++))
> do
> ping -c 1 mercy.com
> done
PING mercy.com (192.168.1.4) 56(84) bytes of data.
64 bytes from heuristics.local (192.168.1.4): icmp_req=1 ttl=64 time=0.027 ms

— mercy.com ping statistics —
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.027/0.027/0.027/0.000 ms
PING mercy.com (192.168.1.3) 56(84) bytes of data.
64 bytes from heuristics (192.168.1.3): icmp_req=1 ttl=64 time=0.035 ms

— mercy.com ping statistics —
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.035/0.035/0.035/0.000 ms
PING mercy.com (192.168.1.8) 56(84) bytes of data.
64 bytes from heuristics.local (192.168.1.8): icmp_req=1 ttl=64 time=0.035 ms

In the above output you can see that the IP of mercy.com changes during each iteration in the loop.

SPECIAL NOTE:

The bind can be configured to return random IP address from the list of A records. All that needs to be done is changing the “rrset-order” from “cyclic” to “random”.

REFERENCES:

http://www.zytrax.com/books/dns/ch9/rr.html#services

http://www.stanford.edu/~riepel/lbnamed/

Advertisements
Categories: DNS
  1. bari
    April 27, 2013 at 3:23 pm

    thenks a lot

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: