-->
Previous Table of Contents Next


As you can see, the format of the resource records gets complicated in a hurry. Things should get clearer as you look at a few of the master configuration files used by named.

The named.hosts File

In your named.boot file, you listed named.hosts as being the file that contains information about your local domain, tristar.com. You could have named the file anything you wanted by listing the name on the primary line of named.boot. The named.hosts file contains authoritative information about the hosts in the zone of authority—tristar.com. Listing 25.1 shows a sample named.hosts file that uses several of the resource record types.

Listing 25.1 An Example named.hosts File


; named.hosts file for tristar.com

;

@      IN    SOA    ns.tristar.com. dave.tristar.com. (

6 ; serial number

86400 ;refresh 24 hrs

300 ; retry 5 minutes

2592000 ; expire 30 days

86400 ; minimum 24 hrs

)

IN     NS      ns.tristar.com.

;

; your domain itself tristar.com

;

@          IN     A     199.198.197.1

IN     MX     100     mailhost.tristar.com

IN     HINFO     PC-486     Linux

;

; your primary nameserver

;

ns          IN     A     199.198.197.1

nameserver     IN     CNAME     ns.tristar.com.

;

; other hosts

;

mailhost     IN     A     199.198.197.2

opus          IN     A     199.198.197.3

IN     MX    100     mailhost.tristar.com

skippy          IN     A     199.198.197.4

IN     MX     100     mailhost.tristar.com

;

; the localhost

;

localhost       IN     A     127.0.0.1


NOTE:  Host names in resource records that end with a. (dot) aren’t translated any further. If the dot isn’t the last character in the host name, named assumes that the host name you gave is relative to the origin domain name referred to by @ and appends the domain name to the host name.

Look at the named.hosts file in Listing 25.1 in detail. The first record that you come to in this file is the SOA (start of authority) record for the example domain. The first line of this record starts with the @ character, which indicates the current origin or domain (tristar.com). The definition of the origin comes from the domain listed on the corresponding primary line in named.boot. After that, you see the codes IN SOA, which tells named that this resource record uses Internet (TCP/IP) addressing and is a start-of-authority record.

The next two entries on the line are the canonical name of the primary name server for this domain (ns.tristar.com), and the e-mail contact with the @ replaced by a dot (dave.tristar.com). You then list the various fields of the data required by an SOA record, one per line. (Refer to Table 25.6 for a complete explanation of each of these entries.)

After the SOA record, the next line is a name-server resource record, which lists ns.tristar.com as being a name server for the domain. Because no domain is listed in the domain field, it’s assumed to be the last domain specified, which was @, listed in the SOA record. And, of course, the @ character really expands to be the local domain, tristar.com. What could possibly be easier to understand?

The next three lines set up some information about the tristar.com domain itself. Although you’ve listed the domain name as @ for clarity because it was the last domain name listed in the file, these resource records still apply to it by default if you had left the domain field blank. The line


@          IN       A       199.198.197.1

allows users to refer to tristar.com as though it were a real machine. It has been assigned the IP address of 199.198.197.1, which, as you’ll see, is really the IP address of ns.tristar.com. The next line sets up a mail exchanger MX record for tristar.com so that all mail going to it gets forwarded to mailhost.tristar.com instead. The last line in this group sets up a host information HINFO record for tristar.com, which tells the world that it’s a PC-486 running Linux.

A few lines earlier in the file, you listed ns.tristar.com as being your name server via an NS resource record. For named to work correctly, you must provide an address or A record that gives the address of ns.tristar.com. The next line in your file does just that. Following the “glue record” that gives the address of the name server, you have a CNAME resource record. This record tells you that nameserver.tristar.com is an alias for ns.tristar.com.

You then proceed to set up address records for three other hosts in your domain: mailhost, opus, and skippy. Notice that after the A records for opus and skippy are MX records that route any mail received by opus or skippy to mailhost.tristar.com. Because no name was specified in the first field of these MX records, they apply to the previous name—opus or skippy.


NOTE:  Because the owner field of a resource record defaults to the last one specified if it’s left blank, it’s easy to group records that apply to one host. However, you must be careful if you add new records for new hosts to a file. If you add them to the middle of a file, you may cause the default host to change for some of the existing resource records. Look carefully before you add resource records to an existing file.

Finally, the last host in this named.hosts file is the localhost, which is mapped to address 127.0.0.1. As you can see, the syntax for these files gets quite complicated and gives you lots of room for errors.


Previous Table of Contents Next