DNS zone file Format, Configuration, and Directives
DNS saves its database in zone files. A zone file stores records of a particular domain in simple text format. It contains three types of entries: comments, directives, and resource records.
Comments
A comment starts with a semicolon (;) and continues to the end of the line. You can add a comment to any directive or record. DNS ignores everything you write after a semicolon till the next line. If you put a semicolon at the beginning of a line, DNS ignores the entire line. If you put a semicolon in the middle of the line, DNS ignores everything that comes after the semicolon.
The following are examples of comments.
; This line starts with a semicolon. DNS will not read it. It is an example of a full-line comment. $TTL 12h; DNS will not read this line after the semicolon (;).
Directives
A directive starts with a dollar sign. It works as a variable. It stores value. DNS replaces a directive with its value when it processes the zone file. There are two important directives: $TTL and $ORIGIN.
$TTL
This directive is mandatory. It defines a default Time to Live (TTL) value for resource records.
$ORIGIN
This directive defines the domain or zone name. The domain or zone name must end with a dot. This directive is optional. It allows you to use relative names in the file.
FQDN and Relative names
In the DNS database, a resource's name can be either an FQDN or a relative name.
An FQDN (fully qualified domain name) name is a complete name. It includes the names of all top-level domains till the root domain. It ends with a dot. You can access a resource anywhere in the domain system using its FQDN name. The following are examples of FQDN names.
ca.north.example.co.us., wa.south.example.co.us., la.east.example.co.us. ny.west.example.co.us.
A relative name is a hostname. It may or may not include the parent domain's name. It does not end with a dot. You cannot access a resource outside the domain using its relative name. However, you can access a resource inside the domain using its relative name. The following are examples of relative names.
ca.north, wa.south, la.east, ny.west
You can use both types of names in the zone file, but DNS will process only FQDN names. If you use a relative name in the zone file, DNS automatically converts it into the FQDN name before processing it.
To convert a relative name into the FQDN name, it uses the $ORIGIN directive's value. The $ORIGIN directive stores the FQDN name of the domain. It attaches the domain's FQDN name to the relative name as a suffix to make it the FQDN name. Let's take an example. If the relative name is ca.north and the $ORIGIN directive has the value example.com., then the FQDN name will be ca.north.example.com. (ca.north + example.com.).
Resources records
A resource record defines the characteristics and properties of an entity within the domain. There are many types of resource records. The most important resource record types are SOA, NS, MX, A, AAAA, and PTR.
Formatting records
A zone file uses lines to store resource records. For each record, it uses a separate line. If you want to create a record in multiple lines, use a parenthesis. DNS processes everything you put between an opening parenthesis and a closing parenthesis as a part of the line. Administrators use this feature to make the SOA record more human-readable. The following image shows an example of an SOA record.

DNS will see the SOA record above as follows:
@ IN SOA ns1.example.com. hostmaster.example.com. 2023013100 12h 15m 3w 2h
Spaces and tabs are field separators in a record. Administrators generally use tabs. They provide a more attractive layout and indicate the added and missed fields.
The following records use blank spaces as separators.

With tabs, the above records will look like the following.

As we can see in the above records, if we use tabs to separate the fields in the records, the fields look neat and descriptive. We can easily identify which fields have values and which fields are empty.
The following example zone file summarizes all the topics mentioned above.

Conclusion
A DNS zone file saves resource records. In this tutorial, we learned the meanings of important directives and how to format them to provide information more descriptively.
This tutorial is part of the following tutorial series on DNS server concepts and configurations.
Chapter 01 How to configure DNS Server in Linux
Chapter 02 DNS Basic Concepts, Fundamentals, and Terminology
Chapter 03 DNS Server and Query Types Explained
Chapter 04 The /etc/hosts, /etc/resolv.conf, and /etc/nsswitch.conf files
Chapter 05 The dig command on Linux
Chapter 06 The nslookup command on Linux
Chapter 07 Change or specify the DNS server to the nslookup command
Chapter 08 DNS zone File Format
Chapter 09 The TTL and ORIGIN directives in the zone file
Chapter 10 Types of resources records in zone files
Chapter 11 The SOA Record Explained in the DNS zone file
Chapter 12 The NS Record, Glue record, and Lame Delegation
Chapter 13 The MX record in a zone file explained
Chapter 14 The a, aaaa, and cname DNS record types
Chapter 15 The pointer (PTR) record and Reverse mapping Explained
Chapter 16 How to configure a caching-only name server
Chapter 17 How to configure DNS Forwarding and a forwarder name server
Chapter 18 How to configure a primary or master authoritative name server
Chapter 19 How to configure a secondary or slave authoritative name server
Chapter 20 How to configure reverse mapping on DNS name servers
Author Laxmi Goswami Updated on 2025-10-06