Two types of zone files are needed. One assigns IP addresses to hostnames and the other does the reverse: supplies a hostname for an IP address.
|Using the Dot in Zone Files|
The first case to consider is the zone file
world.zone, responsible for the domain
world.cosmos, shown in Example 24.6, “File /var/lib/named/world.zone”.
Example 24.6. File /var/lib/named/world.zone
$TTL 2D world.cosmos. IN SOA gateway root.world.cosmos. ( 2003072441 ; serial 1D ; refresh 2H ; retry 1W ; expiry 2D ) ; minimum IN NS gateway IN MX 10 sun gateway IN A 192.168.0.1 IN A 192.168.1.1 sun IN A 192.168.0.2 moon IN A 192.168.0.3 earth IN A 192.168.1.2 mars IN A 192.168.1.3 www IN CNAME moon
$TTL defines the default time to live that
should apply to all the entries in this file. In this example, entries
are valid for a period of two days (
This is where the SOA (start of authority) control record begins:
The name of the domain to administer is
in the first position. This ends with a
otherwise the zone would be appended a second time. Alternatively,
@ can be entered here, in which case the zone would
be extracted from the corresponding entry in
IN SOA is the name of the name server in
charge as master for this zone. The name is expanded from
because it does not end with a
An e-mail address of the person in charge of this name server
follows. Because the
@ sign already has a special
. is entered here instead. For
firstname.lastname@example.org the entry must read
. must be included at the end to prevent the
zone from being added.
( includes all lines up to
) into the SOA record.
serial number is an arbitrary number
that is increased each time this file is changed. It is needed to inform
the secondary name servers (slave servers) of changes. For this, a
10 digit number of the date and run number, written as YYYYMMDDNN, has
become the customary format.
refresh rate specifies the time interval at
which the secondary name servers verify the zone
number. In this case, one day.
retry rate specifies the time interval at
which a secondary name server, in case of error, attempts to contact the
primary server again. Here, two hours.
expiration time specifies the time frame
after which a secondary name server discards the cached data if it has
not regained contact to the primary server. Here, it is a week.
The last entry in the SOA record specifies the
caching TTL—the time for which results of
unresolved DNS queries from other servers may be cached.
IN NS specifies the name server responsible
for this domain.
gateway is extended to
gateway.world.cosmos because it does not end
.. There can be several lines like
this—one for the primary and one for each secondary name
notify is not set to
/etc/named.conf, all the name servers listed here
are informed of the changes made to the zone data.
The MX record specifies the mail server that accepts, processes, and
forwards e-mails for the domain
world.cosmos. In this example,
The number in front of the hostname is the preference value. If there
are multiple MX entries, the mail server with the smallest value is taken
first and, if mail delivery to this server fails, an attempt is made
with the next higher value.
These are the actual address records where one or more IP addresses
are assigned to hostnames. The names are listed here without a
. because they do not include their domain, so
world.cosmos is added to all
of them. Two IP addresses are assigned to the host
gateway, because it has two network cards.
Wherever the host address is a traditional one (IPv4), the record is
A. If the address is an IPv6 address,
the entry is marked with
A6. The previous token for
IPv6 addresses was
AAAA, which is now obsolete.
www can be used to address
in-addr.arpa is used for the reverse
lookup of IP addresses into hostnames. It is appended to the network part
of the address in reverse notation. So
192.168.1 is resolved into
Example 24.7, “Reverse Lookup”.
Example 24.7. Reverse Lookup
$TTL 2D 1.168.192.in-addr.arpa. IN SOA gateway.world.cosmos. root.world.cosmos. ( 2003072441 ; serial 1D ; refresh 2H ; retry 1W ; expiry 2D ) ; minimum IN NS gateway.world.cosmos. 1 IN PTR gateway.world.cosmos. 2 IN PTR earth.world.cosmos. 3 IN PTR mars.world.cosmos.
$TTL defines the standard TTL that applies to all entries here.
The configuration file should activate reverse lookup for the
that the zone is called
should not be added to the hostnames. Therefore, all hostnames are entered in their complete form—with their domain and
. at the end. The remaining entries correspond
to those described for the previous
See the previous example for
Again this line specifies the name server responsible for this zone. This
time, however, the name is entered in its complete form with the domain
. at the end.
These are the pointer records hinting at the IP addresses on the
respective hosts. Only the last part of the IP address is entered at the
beginning of the line, without the
. at the end.
Appending the zone to this (without the
.in-addr.arpa) results in the complete IP
address in reverse order.