named
working directory located in /var/named/
by default, and each zone file is named according to the file
option in the zone
statement, usually in a way that relates to the domain in question and identifies the file as containing zone data, such as example.com.zone
.
Path | Description |
---|---|
/var/named/
|
The working directory for the named service. The nameserver is not allowed to write to this directory.
|
/var/named/slaves/
|
The directory for secondary zones. This directory is writable by the named service.
|
/var/named/dynamic/
|
The directory for other files, such as dynamic DNS (DDNS) zones or managed DNSSEC keys. This directory is writable by the named service.
|
/var/named/data/
|
The directory for various statistics and debugging files. This directory is writable by the named service.
|
$
) followed by the name of the directive, and usually appear at the top of the file. The following directives are commonly used in zone files:
$INCLUDE
$INCLUDE
directive allows you to include another file at the place where it appears, so that other zone settings can be stored in a separate zone file.
$INCLUDE /var/named/penguin.example.com
$ORIGIN
$ORIGIN
directive allows you to append the domain name to unqualified records, such as those with the hostname only. Note that the use of this directive is not necessary if the zone is specified in /etc/named.conf
, since the zone name is used by default.
.
character) are appended with example.com
.
$ORIGIN example.com.
$TTL
$TTL
directive allows you to set the default Time to Live (TTL) value for the zone, that is, how long is a zone record valid. Each resource record can contain its own TTL value, which overrides this directive.
$TTL 1D
A
hostname
IN AIP-address
hostname
value is omitted, the record will point to the last specified hostname
.
server1.example.com
are pointed to 10.0.1.3
or 10.0.1.5
.
server1 IN A 10.0.1.3 IN A 10.0.1.5
CNAME
alias-name
IN CNAMEreal-name
CNAME
records are most commonly used to point to services that use a common naming scheme, such as www
for Web servers. However, there are multiple restrictions for their usage:
A
record binds a hostname to an IP address, while the CNAME
record points the commonly used www
hostname to it.
server1 IN A 10.0.1.5 www IN CNAME server1
MX
IN MXpreference-value
email-server-name
email-server-name
is a fully qualified domain name (FQDN). The preference-value
allows numerical ranking of the email servers for a namespace, giving preference to some email systems over others. The MX
resource record with the lowest preference-value
is preferred over the others. However, multiple email servers can possess the same value to distribute email traffic evenly among them.
mail.example.com
email server is preferred to the mail2.example.com
email server when receiving email destined for the example.com
domain.
example.com. IN MX 10 mail.example.com. IN MX 20 mail2.example.com.
NS
IN NS nameserver-name
nameserver-name
should be a fully qualified domain name (FQDN). Note that when two nameservers are listed as authoritative for the domain, it is not important whether these nameservers are secondary nameservers, or if one of them is a primary server. They are both still considered authoritative.
IN NS dns1.example.com. IN NS dns2.example.com.
PTR
last-IP-digit
IN PTRFQDN-of-system
last-IP-digit
directive is the last number in an IP address, and the FQDN-of-system
is a fully qualified domain name (FQDN).
PTR
records are primarily used for reverse name resolution, as they point IP addresses back to a particular name. Refer to Section 12.2.2.4.2, “A Reverse Name Resolution Zone File” for more examples of PTR
records in use.
SOA
@ IN SOAprimary-name-server
hostmaster-email
(serial-number
time-to-refresh
time-to-retry
time-to-expire
minimum-TTL
)
@
symbol places the $ORIGIN
directive (or the zone's name if the $ORIGIN
directive is not set) as the namespace being defined by this SOA
resource record.
primary-name-server
directive is the hostname of the primary nameserver that is authoritative for this domain.
hostmaster-email
directive is the email of the person to contact about the namespace.
serial-number
directive is a numerical value incremented every time the zone file is altered to indicate it is time for the named
service to reload the zone.
time-to-refresh
directive is the numerical value secondary nameservers use to determine how long to wait before asking the primary nameserver if any changes have been made to the zone.
time-to-retry
directive is a numerical value used by secondary nameservers to determine the length of time to wait before issuing a refresh request in the event that the primary nameserver is not answering. If the primary server has not replied to a refresh request before the amount of time specified in the time-to-expire
directive elapses, the secondary servers stop responding as an authority for requests concerning that namespace.
minimum-TTL
directive is the amount of time other nameservers cache the zone's information. In BIND 9, it defines how long negative answers are cached for. Caching of negative answers can be set to a maximum of 3 hours (that is, 3H
).
M
), hours (H
), days (D
), and weeks (W
). Table 12.6, “Seconds compared to other time units” shows an amount of time in seconds and the equivalent time in another format.
Seconds | Other Time Units |
---|---|
60 |
1M
|
1800 |
30M
|
3600 |
1H
|
10800 |
3H
|
21600 |
6H
|
43200 |
12H
|
86400 |
1D
|
259200 |
3D
|
604800 |
1W
|
31536000 |
365D
|
@ IN SOA dns1.example.com. hostmaster.example.com. ( 2001062501 ; serial 21600 ; refresh after 6 hours 3600 ; retry after 1 hour 604800 ; expire after 1 week 86400 ) ; minimum TTL of 1 day
named
service, but can prove useful when providing additional information to the user. Any text after the semicolon character (that is, ;
) to the end of the line is considered a comment. For example:
604800 ; expire after 1 week
SOA
values.
$ORIGIN example.com. $TTL 86400 @ IN SOA dns1.example.com. hostmaster.example.com. ( 2001062501 ; serial 21600 ; refresh after 6 hours 3600 ; retry after 1 hour 604800 ; expire after 1 week 86400 ) ; minimum TTL of 1 day ; ; IN NS dns1.example.com. IN NS dns2.example.com. dns1 IN A 10.0.1.1 IN AAAA aaaa:bbbb::1 dns2 IN A 10.0.1.2 IN AAAA aaaa:bbbb::2 ; ; @ IN MX 10 mail.example.com. IN MX 20 mail2.example.com. mail IN A 10.0.1.5 IN AAAA aaaa:bbbb::5 mail2 IN A 10.0.1.6 IN AAAA aaaa:bbbb::6 ; ; ; This sample zone file illustrates sharing the same IP addresses ; for multiple services: ; services IN A 10.0.1.10 IN AAAA aaaa:bbbb::10 IN A 10.0.1.11 IN AAAA aaaa:bbbb::11 ftp IN CNAME services.example.com. www IN CNAME services.example.com. ; ;
dns1.example.com
and dns2.example.com
, and are tied to the 10.0.1.1
and 10.0.1.2
IP addresses respectively using the A
record.
MX
records point to mail
and mail2
via A
records. Since these names do not end in a trailing period (that is, the .
character), the $ORIGIN
domain is placed after them, expanding them to mail.example.com
and mail2.example.com
.
www.example.com
(WWW), are pointed at the appropriate servers using the CNAME
record.
zone
statement in the /etc/named.conf
similar to the following:
zone "example.com" IN { type master; file "example.com.zone"; allow-update { none; }; };
PTR
resource records are used to link the IP addresses to a fully qualified domain name as shown in Example 12.15, “A reverse name resolution zone file”.
$ORIGIN 1.0.10.in-addr.arpa. $TTL 86400 @ IN SOA dns1.example.com. hostmaster.example.com. ( 2001062501 ; serial 21600 ; refresh after 6 hours 3600 ; retry after 1 hour 604800 ; expire after 1 week 86400 ) ; minimum TTL of 1 day ; @ IN NS dns1.example.com. ; 1 IN PTR dns1.example.com. 2 IN PTR dns2.example.com. ; 5 IN PTR server1.example.com. 6 IN PTR server2.example.com. ; 3 IN PTR ftp.example.com. 4 IN PTR ftp.example.com.
10.0.1.1
through 10.0.1.6
are pointed to the corresponding fully qualified domain name.
zone
statement in the /etc/named.conf
file similar to the following:
zone "1.0.10.in-addr.arpa" IN { type master; file "example.com.rr.zone"; allow-update { none; }; };
zone
statement, except for the zone name. Note that a reverse name resolution zone requires the first three blocks of the IP address reversed followed by .in-addr.arpa
. This allows the single block of IP numbers used in the reverse name resolution zone file to be associated with the zone.