Выбрать главу

Of course, the name server will not keep this information forever; it will discard it after some time. The expiration interval is called the time to live, or TTL. Each datum in the DNS database is assigned such a TTL by administrators of the responsible zone.

Types of Name Servers

Name servers that hold all information on hosts within a zone are called authoritative for this zone, and sometimes are referred to as master name servers. Any query for a host within this zone will end up at one of these master name servers.

Master servers must be fairly well synchronized. Thus, the zone's network administrator must make one the primary server, which loads its zone information from data files, and make the others secondary servers, which transfer the zone data from the primary server at regular intervals.

Having several name servers distributes workload; it also provides backup. When one name server machine fails in a benign way, like crashing or losing its network connection, all queries will fall back to the other servers. Of course, this scheme doesn't protect you from server malfunctions that produce wrong replies to all DNS requests, such as from software bugs in the server program itself.

You can also run a name server that is not authoritative for any domain.[41] This is useful, as the name server will still be able to conduct DNS queries for the applications running on the local network and cache the information. Hence it is called a caching-only server.

The DNS Database

We have seen that DNS not only deals with IP addresses of hosts, but also exchanges information on name servers. DNS databases may have, in fact, many different types of entries.

A single piece of information from the DNS database is called a resource record (RR). Each record has a type associated with it describing the sort of data it represents, and a class specifying the type of network it applies to. The latter accommodates the needs of different addressing schemes, like IP addresses (the IN class), Hesiod addresses (used by MIT's Kerberos system), and a few more. The prototypical resource record type is the A record, which associates a fully qualified domain name with an IP address.

A host may be known by more than one name. For example you might have a server that provides both FTP and World Wide Web servers, which you give two names: ftp.machine.org and www.machine.org. However, one of these names must be identified as the official or canonical hostname, while the others are simply aliases referring to the official hostname. The difference is that the canonical hostname is the one with an associated A record, while the others only have a record of type CNAME that points to the canonical hostname.

We will not go through all record types here, but we will give you a brief example. Example 6.4 shows a part of the domain database that is loaded into the name servers for the physics.groucho.edu zone.

Example 6.4: An Excerpt from the named.hosts File for the Physics Department

; Authoritative Information on physics.groucho.edu.

@ IN SOA niels.physics.groucho.edu. janet.niels.physics.groucho.edu. {

 1999090200; serial no

 360000; refresh

 3600; retry

 3600000; expire

 3600; default ttl

}

;

; Name servers

 IN NS niels

 IN NS gauss.maths.groucho.edu.

gauss.maths.groucho.edu. IN A 149.76.4.23

;

; Theoretical Physics (subnet 12)

niels IN A 149.76.12.1

 IN A 149.76.1.12

name server IN CNAME niels

otto IN A 149.76.12.2

quark IN A 149.76.12.4

down IN A 149.76.12.5

strange IN A 149.76.12.6

; Collider Lab. (subnet 14)

boson IN A 149.76.14.1

muon IN A 149.76.14.7

bogon IN A 149.76.14.12

Apart from the A and CNAME records, you can see a special record at the top of the file, stretching several lines. This is the SOA resource record signaling the Start of Authority, which holds general information on the zone the server is authoritative for. The SOA record comprises, for instance, the default time to live for all records.

Note that all names in the sample file that do not end with a dot should be interpreted relative to the physics.groucho.edu domain. The special name (@) used in the SOA record refers to the domain name by itself.

We have seen earlier that the name servers for the groucho.edu domain somehow have to know about the physics zone so that they can point queries to their name servers. This is usually achieved by a pair of records: the NS record that gives the server's FQDN, and an A record that associates an address with that name. Since these records are what holds the namespace together, they are frequently called glue records. They are the only instances of records in which a parent zone actually holds information on hosts in the subordinate zone. The glue records pointing to the name servers for physics.groucho.edu are shown in Example 6.5.

Example 6.5: An Excerpt from the named.hosts File for GMU

; Zone data for the groucho.edu zone.

@ IN SOA vax12.gcc.groucho.edu. joe.vax12.gcc.groucho.edu. {

 1999070100; serial no

 360000; refresh

 3600; retry

 3600000; expire

 3600; default ttl

}

;

; Glue records for the physics.groucho.edu zone

physics IN NS niels.physics.groucho.edu.

 IN NS gauss.maths.groucho.edu.

niels.physics IN A 149.76.12.1

gauss.maths IN A 149.76.4.23

Reverse Lookups

Finding the IP address belonging to a host is certainly the most common use for the Domain Name System, but sometimes you'll want to find the canonical hostname corresponding to an address. Finding this hostname is called reverse mapping, and is used by several network services to verify a client's identity. When using a single hosts file, reverse lookups simply involve searching the file for a host that owns the IP address in question. With DNS, an exhaustive search of the namespace is out of the question. Instead, a special domain, in-addr.arpa, has been created that contains the IP addresses of all hosts in a reversed dotted quad notation. For instance, an IP address of 149.76.12.4 corresponds to the name 4.12.76.149.in-addr.arpa. The resource-record type linking these names to their canonical hostnames is PTR.

вернуться

41

Well, almost. A name server has to provide at least name service for localhost and reverse lookups of 127.0.0.1.