Este contenido no está disponible en el idioma seleccionado.
17.2.2. Editing Zone Files
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. |
17.2.2.1. Common Directives Copiar enlaceEnlace copiado en el portapapeles!
-
$INCLUDE - The
$INCLUDEdirective 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.Example 17.7. Using the $INCLUDE directive
$INCLUDE /var/named/penguin.example.com
$INCLUDE /var/named/penguin.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
$ORIGIN - The
$ORIGINdirective allows you to append the domain name to unqualified records, such as those with the host name 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.In Example 17.8, “Using the $ORIGIN directive”, any names used in resource records that do not end in a trailing period are appended withexample.com.Example 17.8. Using the $ORIGIN directive
$ORIGIN example.com.
$ORIGIN example.com.Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
$TTL - The
$TTLdirective 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.Increasing this value allows remote nameservers to cache the zone information for a longer period of time, reducing the number of queries for the zone and lengthening the amount of time required to propagate resource record changes.Example 17.9. Using the $TTL directive
$TTL 1D
$TTL 1DCopy to Clipboard Copied! Toggle word wrap Toggle overflow
17.2.2.2. Common Resource Records Copiar enlaceEnlace copiado en el portapapeles!
-
A - The Address record specifies an IP address to be assigned to a name. It takes the following form:
hostname IN A IP-address
hostname IN A IP-addressCopy to Clipboard Copied! Toggle word wrap Toggle overflow If the hostname value is omitted, the record will point to the last specified hostname.In Example 17.10, “Using the A resource record”, the requests forserver1.example.comare pointed to10.0.1.3or10.0.1.5.Example 17.10. Using the A resource record
server1 IN A 10.0.1.3 IN A 10.0.1.5server1 IN A 10.0.1.3 IN A 10.0.1.5Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
CNAME - The Canonical Name record maps one name to another. Because of this, this type of record is sometimes referred to as an alias record. It takes the following form:
alias-name IN CNAME real-name
alias-name IN CNAME real-nameCopy to Clipboard Copied! Toggle word wrap Toggle overflow CNAMErecords are most commonly used to point to services that use a common naming scheme, such aswwwfor Web servers. However, there are multiple restrictions for their usage:- CNAME records should not point to other CNAME records. This is mainly to avoid possible infinite loops.
- CNAME records should not contain other resource record types (such as A, NS, MX, etc.). The only exception are DNSSEC related records (that is, RRSIG, NSEC, etc.) when the zone is signed.
- Other resource record that point to the fully qualified domain name (FQDN) of a host (that is, NS, MX, PTR) should not point to a CNAME record.
In Example 17.11, “Using the CNAME resource record”, theArecord binds a host name to an IP address, while theCNAMErecord points the commonly usedwwwhost name to it.Example 17.11. Using the CNAME resource record
server1 IN A 10.0.1.5 www IN CNAME server1
server1 IN A 10.0.1.5 www IN CNAME server1Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
MX - The Mail Exchange record specifies where the mail sent to a particular namespace controlled by this zone should go. It takes the following form:
IN MX preference-value email-server-name
IN MX preference-value email-server-nameCopy to Clipboard Copied! Toggle word wrap Toggle overflow The 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. TheMXresource 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.In Example 17.12, “Using the MX resource record”, the firstmail.example.comemail server is preferred to themail2.example.comemail server when receiving email destined for theexample.comdomain.Example 17.12. Using the MX resource record
example.com. IN MX 10 mail.example.com. IN MX 20 mail2.example.com.example.com. IN MX 10 mail.example.com. IN MX 20 mail2.example.com.Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
NS - The Nameserver record announces authoritative nameservers for a particular zone. It takes the following form:
IN NS nameserver-name
IN NS nameserver-nameCopy to Clipboard Copied! Toggle word wrap Toggle overflow The 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.Example 17.13. Using the NS resource record
IN NS dns1.example.com. IN NS dns2.example.com.
IN NS dns1.example.com. IN NS dns2.example.com.Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
PTR - The Pointer record points to another part of the namespace. It takes the following form:
last-IP-digit IN PTR FQDN-of-system
last-IP-digit IN PTR FQDN-of-systemCopy to Clipboard Copied! Toggle word wrap Toggle overflow The last-IP-digit directive is the last number in an IP address, and the FQDN-of-system is a fully qualified domain name (FQDN).PTRrecords are primarily used for reverse name resolution, as they point IP addresses back to a particular name. See Section 17.2.2.4.2, “A Reverse Name Resolution Zone File” for more examples ofPTRrecords in use. -
SOA - The Start of Authority record announces important authoritative information about a namespace to the nameserver. Located after the directives, it is the first resource record in a zone file. It takes the following form:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The directives are as follows:- The
@symbol places the$ORIGINdirective (or the zone's name if the$ORIGINdirective is not set) as the namespace being defined by thisSOAresource record. - The primary-name-server directive is the host name of the primary nameserver that is authoritative for this domain.
- The hostmaster-email directive is the email of the person to contact about the namespace.
- The serial-number directive is a numerical value incremented every time the zone file is altered to indicate it is time for the
namedservice to reload the zone. - The 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.
- The 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.
- In BIND 4 and 8, the 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).
When configuring BIND, all times are specified in seconds. However, it is possible to use abbreviations when specifying units of time other than seconds, such as minutes (M), hours (H), days (D), and weeks (W). Table 17.6, “Seconds compared to other time units” shows an amount of time in seconds and the equivalent time in another format.Expand Table 17.6. Seconds compared to other time units Seconds Other Time Units 60 1M1800 30M3600 1H10800 3H21600 6H43200 12H86400 1D259200 3D604800 1W31536000 365DExample 17.14. Using the SOA resource record
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
17.2.2.3. Comment Tags Copiar enlaceEnlace copiado en el portapapeles!
named service, but can prove useful when providing additional information to the user. Any text after the semicolon character to the end of the line is considered a comment. For example:
604800 ; expire after 1 week
604800 ; expire after 1 week
17.2.2.4. Example Usage Copiar enlaceEnlace copiado en el portapapeles!
17.2.2.4.1. A Simple Zone File Copiar enlaceEnlace copiado en el portapapeles!
SOA values.
Example 17.15. A simple zone file
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, 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; };
};
zone "example.com" IN {
type master;
file "example.com.zone";
allow-update { none; };
};
17.2.2.4.2. A Reverse Name Resolution Zone File Copiar enlaceEnlace copiado en el portapapeles!
PTR resource records are used to link the IP addresses to a fully qualified domain name as shown in Example 17.16, “A reverse name resolution zone file”.
Example 17.16. A reverse name resolution zone file
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 "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.