In Computer Networking, a zone file is a text file that describes a portion of the domain name system (DNS) called a DNS zone. A zone contains information that defines mappings between domain names and IP addresses and other resources, organized in form of resource records (RR).
The format of a zone file is defined in RFC 1035 section 5 and RFC 1034 section 3.6.1. This format was originally used by the Berkeley Internet Name Domain (BIND) software package, but has been widely adopted by other DNS server software. Each line typically defines a single resource record. A line begins with a domain name, but if left blank, defaults to the previously defined domain name. Following the domain name is the TTL, the class (which is almost always "IN" for "internet" and rarely included), the type of resource record (A, MX, SOA, etc.), followed by type-specific data such as the IPv4 address for A records. Comments can be included by using a semi-colon and lines can be continued by using parenthesis. There are also file directives that are marked with a keyword starting with a dollar-sign.
A simple example of a zone file:
$ORIGIN example.com. ; designates the start of this zone file in the name space
$TTL 1h ; The default expiration time of a resource record without its own TTL value
example.com. IN SOA ns.example.com. username.example.com. (
2007120710 ; serial number of this zone file
1d ; slave refresh (1 day)
1d ; slave retry time in case of a problem (1 day)
4w ; slave expiration time (4 weeks)
1h ; minimum caching time in case of failed lookups (1 hour)
)
example.com. NS ns ; ns.example.com is the nameserver for example.com
example.com. NS ns.somewhere.com. ; ns.somewhere.com is a backup nameserver for example.com
example.com. MX 10 mail.example.com. ; mail.example.com is the mailserver for example.com
@ MX 20 mail2.example.com. ; Similar to above line, but using "@" to say "use $ORIGIN"
@ MX 50 mail3 ; Similar to above line, but using a host within this domain
example.com. A 10.0.0.1 ; ip address for "example.com"
ns A 10.0.0.2 ; ip address for "ns.example.com"
www CNAME ns ; "www.example.com" is an alias for "ns.example.com"
wwwtest CNAME www ; "wwwtest.example.com" is another alias for "www.example.com"
mail A 10.0.0.3 ; ip address for "mail.example.com", any MX record host must be
; an A or AAAA record, it should never be a CNAME record
; as explained in RFC 2181 (section 10.3)
As a minimum, the zone file should specify the default "time to live" (TTL) for a record in a client's cache after which it should repeat the lookup, and the 'Start of Authority' (SOA) record with the name of the primary authoritative nameserver for the zone, the email address of someone responsible for management of the nameserver and the zone, and some information for backup nameservers, that is, other servers that keep a backup copy of the zone information in case the main nameserver is not reachable. The email address has the @ symbol replaced by a period (.). In the zone file, host names that do not end in a period are assumed to be relative to the zone origin. For example, in the example above, "www" refers to "www.example.com", but "example.com." does not refer to "example.com.example.com", but rather to "example.com". Names ending with a period are said to be 'fully qualified' domain names.
A zone file is referenced by the configuration file of the nameserver software such as bind, typically by a statement such as:
zone "example.com" { type master; file "/var/named/db.example.com"; };
References
- RFC 1035 (P. Mockapetris, November 1987) - defines the binary format of resource records
See also