Installing master and slave DNS Servers using Bind 9 on Ubuntu

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
$ORIGIN domain.com.
@                      3600 SOA   ns1.domain.com. (
                              dnsmaster.domain.com.     ; address of responsible party
                              2016072701                 ; serial number
                              3600                       ; refresh period
                              600                        ; retry period
                              604800                     ; expire time
                              1800                     ) ; minimum 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

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

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

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.