This guide explains how to create a DNS zone for my.kodekloudlab.com using BIND9, including configuring SOA and NS records.
In this guide, we will walk through creating a DNS zone for my.kodekloudlab.com using BIND9. You will learn how to update the configuration file to define the zone and create its corresponding zone file with the proper SOA and NS records.
To configure the new zone, open the file named.conf.local using a text editor like Vim. You may remove the default comments and any pre-populated lines to start fresh.
Inside named.conf.local, add the following zone definition for my.kodekloudlab.com. The configuration specifies that this server is the primary (master) for the zone, and it points to the corresponding zone file where the DNS records are stored.
Copy
zone "my.kodekloudlab.com" { type master; # This indicates the server is the primary DNS server for this zone file "/etc/bind/db.my.kodekloudlab.com"; # Path to the zone file};
By convention, the zone file resides in the /etc/bind directory and is usually named with a db. prefix followed by the domain name. Open both the configuration file and the zone file for editing with the following commands:
Copy
bob@node01 ~ $ sudo vi /etc/bind/named.conf.localbob@node01 ~ $ sudo vi /etc/bind/db.my.kodekloudlab.com
Inside the zone file, start by defining the mandatory parameters:
The TTL (Time To Live) value is set to 300 seconds, which establishes the default caching period for DNS records.
The SOA (Start of Authority) record declares the primary name server for the zone and includes essential maintenance values such as Serial, Refresh, Retry, Expire, and Negative Cache TTL.
Remember to increment the Serial number each time you update the zone file.
Enter the following content into the zone file:
Copy
@ $TTL 300 IN SOA ns1.my.kodekloudlab.com. admin.my.kodekloudlab.com. ( 1 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 604800 ) ; Negative Cache TTL
After setting up the SOA record, add the NS record to identify the authoritative name server for the zone:
Copy
@ IN NS ns1.my.kodekloudlab.com.
These configurations establish the basic structure required for managing your DNS zone.Save the zone file and exit the editor.
Even with the correct configuration, querying the domain (using a command-line tool like dig) may not yield the expected results if a glue record is missing for the declared name server. Without a proper glue record, queries for ns1.my.kodekloudlab.com might fail, leading to issues with resolving my.kodekloudlab.com.Run the following command to verify:
If you encounter an NXDOMAIN status, it may be due to the missing glue record for ns1.my.kodekloudlab.com. In the next article, we will discuss how to add this glue record, ensuring your local DNS server resolves the name server correctly.
By following these steps, you have successfully configured a DNS zone for my.kodekloudlab.com on your BIND9 server. For additional DNS configuration tips and best practices, explore our related documentation and resources.