Installing master and slave DNS Servers using Bind 9 on Ubuntu 12.04

On the master server install bind server and bind utilities:

sudo apt-get install bind9 bind9util

Once bind has been installed, you need to setup the zones you will be hosting.  In this example,  domain.com is your domain name, 60.60.20.15 is the IP address or your slave server, and 50.50.20.15 is the IP address of your master server:

sudo nano named.conf.local

Add the details of your zone

zone "domain.com" IN {
type master;
file "/etc/bind/zones/domain.com.db";
allow-transfer { 60.60.20.15; };
also-notify { 60.60.20.15;};
};

Now we need to add some additional settings to your DNS server for security:

sudo nano named.conf.options

Add this just below the directory “/var/cache/bind”; entry

recursion no;
additional-from-auth no;
additional-from-cache no;
version "Bind Server";

Also remark out IPV6 (unless you intend to use it):

// listen-on-v6 { any; };

Now you need to create a zone file for your domain:

sudo nano /etc/bind/zones/domain.com.db
$TTL 3600 ; Default record TTL
@ IN SOA ns1.domain.com. dnsmaster.domain.com. (
2013071101 ; Date based serial number.
21600 ; Secondary server refresh TTL
3600 ; Secondary refresh failure try again TTL
604800 ; Secondary zone keep alive if primary unavailable
1800 ) ; Negative Cache TTL
;
IN NS ns1.domain.com
IN NS ns2.domain.com

;
ns1 IN A 50.50.20.15
ns2 IN A 60.60.20.15
@  IN A 50.50.20.20
www  IN A 50.50.20.20

Now restart bind to make the changes we have made active.

sudo service bind9 restart

 

On the slaveserver install bind server and bind utilities:

sudo apt-get install bind9 bind9util

Once bind has been installed, you need to setup the zones you will be hosting.  In this example,  domain.com is your domain name, 60.60.20.15 is the IP address or your slave server, and 50.50.20.15 is the IP address of your master server:

sudo nano /etc/bind/named.conf.local

Add the details of your zone

zone "domain.com" IN {
type slave;
file "/var/cache/bind/domain.com.db";
masters {50.50.20.15;};
allow-transfer {"none";};
allow-notify { "none";};
};

Now we need to add some additional settings to your DNS server for security:

sudo nano named.conf.options

Add this just below the directory “/var/cache/bind”; entry

recursion no;

additional-from-auth no;
additional-from-cache no;
version "Bind Server";

Also remark out IPV6 (unless you intend to use it:

// listen-on-v6 { any; };

Now restart bind to make the changes active:

sudo services bind9 restart

 

You can now check that the zone files have been transferred by listing the content of the directory on your slave server:

cd /var/cache/bind/
ls -al

You should now see the file domain.com.db listed

 

If you need to troubleshoot, errors can be found in the /var/log/syslog