Skip to main content

DNS and BIND: Create a Forward Zone File

Hands-On Lab

 

Photo of Cara Nolte

Cara Nolte

Linux Training Architect II

Length

00:15:00

Difficulty

Intermediate

Zone files are a key component of configuring DNS servers. In this lab we will configure a forward zone file, and add TTL, SOA, NS and A records. This allows a name server to resolve a query, given the hostname, and returns the IP address. This is the most common type of DNS query.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

DNS and BIND: Create a Forward Zone File

Introduction

Zone files are key components of setting up a DNS servers. In this lab we will configure a forward zone file, and add TTL, SOA, NS and A records. This allows a name server to resolve a query, given the hostname, and returns the IP address. This is the most common type of DNS query.

The Scenario

ABC Company is currently in the process of setting up their own internally-hosted DNS service. The next phase of the project is to create the forward zone files. The DNS administrator fell sick and is unavailable, but there the project has a tight timeline. We have been designated as a resource to create the forward zone files until the DNS Administrator returns.

To complete this lab, we need to create and open the forward zone file, /var/named/fwd.labdomain.com.db.

Logging In

Use the credentials provided on the hands-on lab page to get into Server1 to begin with. Since we need root privileges, let's just run sudo -i right off and become root.

Install and Start the Named Service, then Create the File, /var/named/fwd.labdomain.com.db

Let's install BIND, then get it started:

yum install -y bind
systemctl start named

Now we can use whichever editor is handy to make changes to the db file. The lab video shows vim:

vim /var/named/fwd.labdomain.com.db

Add the TTL and SOA Records to the Zone File


$TTL 86400  

@       IN      SOA     nameserver.labdomain.com.     root.labdomain.com.      (
                               10030   ;Serial
                               3600    ;Refresh
                               1800    ;Retry
                               604800  ;Expiry
                               86400   ;Minimum TTL
)

Add the NS Record to the Zone File

     @       IN      NS      nameserver.labdomain.com.

Add the A Records to the Zone File

nameserver      IN      A       172.31.18.93
mailprod        IN      A       172.31.18.30
mailbackup      IN      A       172.31.18.72

Add the CNAME Record to the Zone File

dns     IN      CNAME   nameserver.labdomain.com.

The Finished File

Save it and quit the editor now, and this is what our final file will look like:

$TTL 86400
@       IN      SOA     nameserver.labdomain.com.     root.labdomain.com.      (
                                10030   ;Serial
                                3600    ;Refresh
                                1800    ;Retry
                                604800  ;Expiry
                                86400   ;Minimum TTL
)
; Name Server
@       IN      NS      nameserver.labdomain.com.
;A Record Definitions
nameserver      IN      A       172.31.18.93
mailprod        IN      A       172.31.18.30
mailbackup      IN      A       172.31.18.72
; Canonical Name/Alias
dns     IN      CNAME   nameserver.labdomain.com.

Conclusion

That's a whole forward zone file, all ready to go. Congratulations!