This guide demonstrates how to configure a multi-node DNS setup with two nameservers and one webserver acting as a client.
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:
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:
Copy
Ask AI
zone "multinode.kodekloud.lab" { type master; file "/etc/bind/db.multinode.kodekloud.lab";};
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.
Run the following commands to check the IP addresses of node-01 and node-02:
Copy
Ask AI
# Starting the named service if not already runningsudo systemctl start named# Editing configuration and zone filesudo vi /etc/bind/named.conf.localsudo vi /etc/bind/db.multinode.kodekloud.lab# Checking IP addresses:ping node01ping node02
Example output for node01:
Copy
Ask AI
PING node01 (192.5.84.8) 56(84) bytes of data.64 bytes from node01 (192.5.84.8): icmp_seq=1 ttl=64 time=0.029 ms
And for node02:
Copy
Ask AI
PING node02 (192.5.84.10) 56(84) bytes of data.64 bytes from node02 (192.5.84.10): icmp_seq=1 ttl=64 time=0.035 ms
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:
Copy
Ask AI
$TTL 604800@ IN SOA node01.multinode.kodekloud.lab. admin.multinode.kodekloud.lab. ( 1 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 604800 ) ; Negative Cache TTL@ IN NS node01.multinode.kodekloud.lab.@ IN NS node02.multinode.kodekloud.lab.node01 IN A 192.5.84.8node02 IN A 192.5.84.10node03 IN A 192.5.84.12
Verify node-02’s configuration by querying for zone data:
Copy
Ask AI
# Query using dig on node-02 itselfdig @localhost multinode.kodekloud.lab# Test full zone transfer using AXFR if permitteddig @192.5.84.10 multinode.kodekloud.lab AXFR
If the zone transfer is successful, node-02 should return all the zone records.
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:
Copy
Ask AI
$TTL 604800@ IN SOA node01.multinode.kodekloud.lab. admin.multinode.kodekloud.lab. ( 1 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 604800 ) ; Negative Cache TTL@ IN NS node01.multinode.kodekloud.lab.@ IN NS node02.multinode.kodekloud.lab.node01 IN A 192.5.84.8node02 IN A 192.5.84.10node03 IN A 192.5.84.12www IN CNAME node03.multinode.kodekloud.lab.
Finally, validate the full setup on node-03 by running:
Copy
Ask AI
curl www.multinode.kodekloud.lab
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.