Jump to content

Zone file

From Wikipedia, the free encyclopedia

DNS Zone File
Filename extension
.zone
Internet media type
text/dns
Developed byISI
Initial release1987;37 years ago(1987)
Type of formatFile format
StandardsRFC1034,1035,2308,4027
Open format?Yes

ADomain Name System(DNS)zone fileis atext filethat describes aDNS zone.A DNS zone is a subset, often a single domain, of the hierarchical domain name structure of the DNS. The zone file contains mappings betweendomain namesandIP addressesand other resources, organized in the form of text representations ofresource records(RR). A zone file may be either a DNS master file, authoritatively describing a zone, or it may be used to list the contents of a DNS cache.[1]

File format

[edit]

The format of a zone file is defined inRFC1035(section 5) andRFC1034(section 3.6.1). This format was originally used by theBerkeley Internet Name Domain(BIND) software package, but has been widely adopted by other DNS server software – though some of them (e.g.NSD,PowerDNS) are using the zone files only as a starting point to compile them into database format, see alsoMicrosoft DNSwithActive Directory-database integration.

A zone file is a sequence of line-oriented entries, each of which is either adirectiveor a text description that defines a singleresource record(RR). An entry is composed of fields separated by any combination of white space (tabs and spaces), and ends at a line boundary except inside a quoted string field value or a pair of enclosing formatting parentheses. Any line may end with comment text preceded by a semicolon, and the file may also contain any number of blank lines.

Entries may occur in any order in a zone file with an exception thatSOArecord must be at top of the zone.

Directives are control entries that affect the rest of the zone file. The first field of a directive consists of a dollar sign followed by a keyword:

  • $ORIGIN is followed by a domain name to be used as the origin for subsequent relative domain names.
  • $INCLUDE is followed by a file name and optional origin domain name to be used when interpreting its contents (which are treated as if they appeared in the parent file, followed by a reset to the origin value preceding evaluation of the directive).
  • $TTL, defined inRFC2308(section 4), is followed by a number to be used as the defaultTTL (time-to-live).
  • $GENERATE, a non-standard extension accepted by BIND and some othername serversoftware to insert multiple resource records with one entry, is followed by a concise representation of an increasing sequence of nonnegative numbers and then a template RR entry. A resource record is added for each number in the sequence, using the template with unescaped "$" characters replaced by the number.

A resource record entry consists of several fields as follows (both field orderings are acceptable and may be used interchangeably):

name ttl record class record type record data
name record class ttl record type record data

Thenamefield may be left blank. If so, the record inherits the field from the previous record. A free standing @ is used to denote the current origin.

Thettlfield specifies the number of seconds after which a caching client must discard the record and perform a new resolution operation to obtain fresh information. Some name servers, including BIND, allow nonstandard representations that use time unit abbreviations (for example, "2d" meaning two 24-hour days or "1h30m" meaning one hour and 30 minutes). It may be omitted, in which case the resulting value will be set from the default TTL (if defined) or from the preceding record.

Therecord classfield indicates the namespace of the record information. It may be omitted, in which case the resulting value will be set from the preceding record. The most commonly used namespace is that of the Internet, indicated by parameterIN,but others exist and are in use, e.g.,CHAOS.

Therecord typefield is an abbreviation for the type of information stored in the last field,record data.For example: anaddress record(typeAfor IPv4, or typeAAAAfor IPv6,) maps the domain name from the first field to anIP addressin the record data; amail exchangerrecord (typeMX) specifies theSimple Mail Transfer Protocol(SMTP) mail host for a domain.

Therecord datafield may consist of one or more information elements, depending on the requirements of each record type. For example, an address record only requires an address, while a mail exchanger record requires a priority and a domain name. Such information elements are represented as fields separated by white space.

Example file

[edit]

An example of a zone file for the domainexampleis the following:

$ORIGINexample.;designates the start of this zone file in the namespace
$TTL3600;default expiration time (in seconds) of all RRs without their own TTL value
example.INSOAns.example.username.example.(20200910257200360012096003600)
example.INNSns;ns.example is a nameserver for example
example.INNSns.somewhere.example.;ns.somewhere.example is a backup nameserver for example
example.INMX10mail.example.;mail.example is the mailserver for example
@INMX20mail2.example.;equivalent to above line, "@" represents zone origin
@INMX50mail3;equivalent to above line, but using a relative host name
example.INA192.0.2.1;IPv4 address for example
INAAAA2001:db8:10::1;IPv6 address for example
nsINA192.0.2.2;IPv4 address for ns.example
INAAAA2001:db8:10::2;IPv6 address for ns.example
wwwINCNAMEexample.;example is an alias for example
wwwtestINCNAMEwww;wwwtest.example is another alias for example
mailINA192.0.2.3;IPv4 address for mail.example
mail2INA192.0.2.4;IPv4 address for mail2.example
mail3INA192.0.2.5;IPv4 address for mail3.example

At minimum, the zone file must specify theStart of Authority(SOA) record with the name of the authoritative master name server for the zone and the email address of someone responsible for management of the name server (represented as a domain name, with a full stop character in place of the usual@symbol). The parameters of the SOA record also specify a list of timing and expiration parameters (serial number, slave refresh period, slave retry time, slave expiration time, and the maximum time to cache the record). Some name servers, including BIND, also require at least one additional NS record.

In the zone file, domain names that end with a full stop character (such as "example."in the above example) arefully qualifiedwhile those that do not end with a full stop are relative to the current origin (which is whywwwin the above example refers toexample).

A zone file is referenced by the configuration file of the name server software. For example, BIND typically uses a statement such as:

zone "example" { type master; file "/var/named/db.example"; };

Root zone and top-level domains

[edit]

The zone files for theDNS root zoneand for the set oftop-level domainscontain resource records only for the authoritative domain name servers for each domain name.

Some server software automatically configures resource records for specially recognized domains or hostnames, such aslocalhost,but a customized zone master file may be used.

An example for manual configuration of the forward zone forlocalhostis the following:

$ORIGINlocalhost.
@86400INSOA@root(
1999010100;serial
10800;refresh (3 hours)
900;retry (15 minutes)
604800;expire (1 week)
86400;minimum (1 day)
)
@86400INNS@
@86400INA127.0.0.1
@86400INAAAA::1

The corresponding reverse zone definition is:

;; reverse zone file for 127.0.0.1 and::1
$TTL1814400;3 weeks
@1814400INSOAlocalhost.root.localhost.(
1999010100;serial
10800;refresh (3 hours)
900;retry (15 minutes)
604800;expire (1 week)
86400;minimum (1 day)
)
@1814400INNSlocalhost.
11814400INPTRlocalhost.

This file does not specify the origin so that it may be used for both IPv4 and IPv6 with this configuration:

zone "0.0.127.in-addr.arpa" IN {
type master;
file "r.local";
};
zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" IN {
type master;
file "r.local";
};

Similar zone master files may be created for the reverse resolution of the broadcast address and the null address. Such zone files prevent a DNS server from referring to other, possibly external DNS servers.

See also

[edit]
[edit]

References

[edit]
  1. ^RFC1035,Domain Names - Implementation and Specification,P. Mockapetris, (November 1987)