Skip to main content
In this guide, we will demonstrate how to configure a multi-node DNS setup consisting of two nameservers and one webserver that also acts as a client. The configuration details are as follows: • node-01: Primary nameserver
• node-02: Secondary nameserver
• node-03: Webserver running an application (and acting as a client)
Below is an illustration of the multi-node DNS setup:
The image illustrates a multi-node DNS setup with three nodes: a primary nameserver, a secondary nameserver, and a web nameserver, along with a client icon.

Primary Nameserver Setup (node-01)

Begin by installing and configuring BIND9 on node-01, which will serve as the primary nameserver.

1. Install and Start BIND9

Start the BIND9 service:

2. Configure the Zone File

Edit the zone configuration file (typically named.conf.local) to specify the zone information. In this example, our domain is multinode.kodekloud.lab and its zone file is stored in /etc/bind. The configuration should indicate that node-01 is the primary (master) server for the zone:
Gather the IP addresses for node-01 and node-02 before updating the zone file. These IP addresses will be used within the zone file.

3. Verify IP Addresses

Run the following commands to check the IP addresses of node-01 and node-02:
Example output for node01:
And for node02:

4. Create the Zone File

Create the file /etc/bind/db.multinode.kodekloud.lab with the following content. This file sets the Start of Authority (SOA) record, NS records, and A records for node01, node02, and node03:

5. Restart and Verify

After saving the zone file, restart the BIND9 service:
You can test the DNS resolution by querying the domain using the local nameserver:
This should return the SOA along with the NS records, confirming that node-01 is correctly serving as the primary nameserver.

Secondary Nameserver Configuration (node-02)

Next, configure node-02 as the secondary (slave) nameserver.

1. Install BIND9 on node-02

SSH into node-02 and start the BIND9 service:

2. Confirm the Primary Server’s IP

From node-02, verify the IP address of node-01:

3. Configure the Secondary Zone

Edit the named.conf.local file on node-02 to declare it as a secondary nameserver. Use node-01’s IP (192.5.84.8) as the master:
Save the file and reload BIND9:

4. Configure Zone Transfer on the Primary (node-01)

Ensure that the named.conf.options file on node-01 allows transfers to node-02. An example configuration:
Reload the service after making changes:

5. Test the Secondary Setup

Verify node-02’s configuration by querying for zone data:
If the zone transfer is successful, node-02 should return all the zone records.

Webserver (node-03) Configuration

Now, configure node-03 as the webserver and set it up to work with DNS.

1. Set Up Nginx on node-03

SSH into node-03, install Nginx, and start the service:
A successful response should display the default Nginx welcome page.

2. Add a CNAME Record for the Webserver

Update the zone file on the primary nameserver (node-01) by adding a CNAME record for the webserver. SSH into node-01 again and open the zone file /etc/bind/db.multinode.kodekloud.lab to include the following record:
After saving the updated file, reload BIND9:

3. Update DNS Settings on node-03

On node-03, update the /etc/resolv.conf file to use node-01’s IP as the primary nameserver. An example resolv.conf might look like:

4. Verify DNS Resolution

Finally, validate the full setup on node-03 by running:
A successful output displaying the Nginx welcome page HTML confirms that the DNS resolution across both nameservers is working correctly.
Through these detailed steps, you have successfully set up a multi-node DNS configuration with a primary nameserver (node-01), a secondary nameserver (node-02), and a webserver (node-03) hosting an Nginx service with a CNAME record pointing to it. This setup ensures reliable DNS resolution across your multi-node environment.

Watch Video

Practice Lab