Skip to main content
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.

1. Check and Start the BIND9 Service

Before modifying any configuration, check the status of the BIND9 service. If it isn’t running, start it with the command below:

2. Update the BIND Configuration

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.
The image shows a blank text editor screen with a dark background, likely indicating an empty file in a terminal-based editor like Vim.
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.
Save the file once you have made these changes.

3. Create 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:
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:
After setting up the SOA record, add the NS record to identify the authoritative name server for the zone:
These configurations establish the basic structure required for managing your DNS zone. Save the zone file and exit the editor.

4. Validate and Test the DNS Configuration

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.

Watch Video