Basic master and slave DNS setup with Bind

DNS or Domain Name System is one of the most important building blocks of the modern IT and internet. DNS allows you to use meaningful names instead of IP addresses. Especially since IPv6 is getting more popular, DNS remains a very important part of your network. This article will describe how to set up a basic master DNS-server and a slave which will replicate the data from the master.

Why a master and a slave

No single system or installation has a perfect 100% uptime and since DNS can be a quite critical component of your network, it is recommended to have a secondary DNS to provide a backup in case the primary one fails. You could simply set up two equal DNS-servers which have the same configuration and data. While this would perfectly work, it would require you to do all changes two times. Once on the primary and once on the secondary.

By setting up one server as the master and the other as the slave, the slave will replicate it’s zone-data from the master to itself. This way, when making changes in some zone on the master, the slave gets notified and takes over the changes almost instantly without the need to do any configuration on the slave’s side.

The master

The example will be done with CentOS 7 but the syntax of the commands should be equal for almost all Linux and Unix variants since Bind is quite universal.

We will start by configuring a single master DNS. The IP of the machine which will be the master is

The first step is to install bind and bind-utils:

After the installation, perform a basic bind configuration by adjusting the sample configuration file in /etc/named.conf. We will also add two test zones.

/etc/named.conf on the master:

The above file differs from the supplied example on the following lines:

2: added this machines IP address
3: commented the line since we don’t do anything with IPv6 here
8: allow querying from everywhere
9: disable recursion by default (you don’t want this on a public DNS)
10+11: disable DNSsec
24-30: a test zone called “blaat.test”
31-37: a test zone called “miauw.test”

In the configuration file, we specified that the data for the zones can be found in the files /var/named/data/db.miauw.test and /var/named/data/db.blaat.test. We need to create those files and enter some zone-data:



After performing the above steps, we can verify if the syntax in our configuration and zone files is correct before starting the service.

In the above example, the syntax seems to be ok so we can start the master:

When all goes well and we don’t receive any warning messages, we can test our freshly created master DNS-server:

Adding zone data

When information is changed for a certain zone, we can simply edit the relevant zone file and update the serial in that file. After checking the syntax, a reload makes sure that the server will reply with the newly provided information.

Edit /var/named/data/db.miauw.test to test updating. Don’t forget to update the serial on the second line:

Now, check the syntax, reload the zone-information and test the newly added information:

Add a slave DNS to the master

Now that our master is fine, it’s time to add a slave DNS-server to the master.

The slave will be running on another machine. In our example, the slave’s IP address will be

Like with the master, we need to install bind on the slave too:

After installation, we need to configure the slave’s /etc/named.conf to behave as a slave for the previously configured master.

/etc/named.conf on the slave:

As you can see, the configuration is quite similar in comparison with the master. The slave’s configuration also contains the same zones as on the master and they are configured as type slave. Zone files don’t need to be created since they should be replicated from the master.

In order to let the master notify the slave when a zone is updated and to allow the zone transfers, we need to add the following lines to the master’s /etc/named.conf in the options{}-section:

The next step is to reload the configuration at the master, since we changed it and to start the slave:

If all goes well, the slave should have replicated the zone information from the master and created it’s zone files on the location that was specified in /etc/named.conf on the slave.

By looking at /var/named/data/ on the slave, you can see that the data was transferred from the master.

To be sure that our slave DNS-server contains the correct data, we can do a query using that server:

Test replication from the master to the slave

To be completely sure that data flows from the master to the slave and that the slave is notifies when a zone is updated on the master, we can simply update a zone and see if the data is available on the slave:

Update the zone in /var/named/data/db.blaat.test (don’t forget about the serial):

Check the syntax and reload the zone configuration:

After reloading the zone on the master, check if the data is automatically transferred to the slave:

This should be all you need to create a simple master and slave DNS-server with Bind.

Leave a Reply

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