A zone file is a text document used by the domain name system (DNS) to map computers, domain names, and various resources to the appropriate Internet Protocol (IP) addresses. This mapping allows people to access resources and computers on the Internet using human-readable addresses. Zone files generally consist of two parts: directives and resource records.
Directives begin with a dollar sign, and include information that applies to the entire zone file, such as its time to live ($TTL). TTL is the default amount of time a name server should consider downloaded zone file information valid before checking for updates. For example, if the $TTL is set to 86,400 seconds (24 hours), a name server accessing that zone file will store a copy of it for 24 hours before attempting to look for an updated version. Note that individual resource records may include unique TTL information that overrides this default value.
Other common directives include $ORIGIN, which sets the default domain name for all hosts included in the zone file, and $INCLUDE, which allows a zone file to include the contents of other text files. Using $INCLUDE files gives administrators the ability to logically organize and separate a zone file’s resource records. This prevents the need to add hundreds of entries to a single file.
Resource records are the zone file entries that define DNS information about a specific host or resource. While there are dozens of types of resource records defined by the Internet Engineering Task Force (IETF), the most commonly used are:
- A record – An Internet Protocol version 4 (IPv4) address record. These records map specific hosts to their assigned IP addresses.
- MX record – A mail exchange record. MX records list the name of the mail servers for this DNS zone. A zone file can contain multiple MX records, each with a specified preference relative to each other.
- CNAME record – Canonical name record. CNAME records are similar to A records, but are used to map one name to another name instead of to an IP address.
- NS record – Name server records. These records define which name servers are authoritative for the domain referenced by the zone file.
- SOA record – Start of authority record. SOA records define parameters that affect the entire zone. These records are essential for the DNS to work properly, especially zone file transfers between primary and secondary DNS servers.
An SOA record lists, among other information, the root domain name for the zone, the serial number for the zone file, and the refresh interval. The refresh interval is the amount of time secondary DNS servers will let pass before attempting to copy the zone file from the primary server. Secondary DNS servers use the serial number to determine whether the copy they already have is the most up-to-date version.