Полезная информация

DNS & BIND

DNS & BINDSearch this book
Previous: 4.2 Setting Up DNS DataChapter 4
Setting Up BIND
Next: 4.4 Abbreviations
 

4.3 Setting Up a BIND Configuration File

Now that the db files have been created, a name server must be instructed to read each of the files. For BIND, the mechanism for pointing the server to its db files is the configuration file. Up to this point, we've been discussing files whose data and format are described in the DNS specification. The configuration file, though, is specific to BIND and is not defined in the DNS RFCs.

The BIND configuration file syntax changed significantly between version 4 and version 8. We'll first show you the BIND 4 syntax and then we'll show you the equivalent BIND 8 syntax. You'll have to check the named[1] manual page to find out which you need to use. If you already have a version 4 configuration file, you can convert it to a version 8 configuration file by running the Perl script src/bin/named/named-bootconf.pl that is distributed with the BIND source.

[1] named is pronounced "name-dee" and stands for "name server daemon." BIND is pronounced to rhyme with "kind." Some creative people have noticed the similarities in the names and choose to mispronounce them "bin-dee" and "named" (like "tamed").

In BIND 4, comments in the configuration file are the same as in the db files - they start with a semicolon and finish at the end of the line:

; This is a comment

In BIND 8, you can use any of 3 styles of comments: C-style, C++-style, or shell-style:

/* This is a C-style comment */
// This is a C++-style comment
# This is a shell-style comment

Don't use a version 4 style comment in a version 8 configuration file because it won't work - the semicolon ends a configuration statement instead of starting a comment statement.

Usually, configuration files contain a line indicating the directory where the files are located. The name server changes its directory to this location before reading the files. This allows the filenames to be relative to the current directory instead of being complete path names. Here is how a version 4 directory line looks:

directory /usr/local/named

Here is how a version 8 directory line looks:

options {
        directory "/usr/local/named";
        // Place additional options here.
};

NOTE: Only one options statement is allowed in the configuration file, so any additional options mentioned later in this book must be added along with the directory option.

On a primary master server, the configuration file contains one line for each file to be read. For version 4, this line comprises three fields: the word primary, starting in the first column, the domain name of the zone, and the filename:

primary  movie.edu                db.movie
primary  249.249.192.in-addr.arpa db.192.249.249
primary  253.253.192.in-addr.arpa db.192.253.253
primary  0.0.127.in-addr.arpa     db.127.0.0

For version 8, the line starts with the keyword zone followed by the domain name and the class (in stands for Internet). The type master is the same as the version 4 primary. The last field is the filename:

zone "movie.edu" in {
      type master;
      file "db.movie";
};

Here is the version 4 configuration file line to read the cache file:

cache  .  db.cache

and the equivalent version 8 configuration file line:

zone "." in {
        type hint;
        file "db.cache";
};

As mentioned earlier, this file is not for general cache data. It only contains the root name server hints.

By default, BIND 4 expects the configuration file to be named /etc/named.boot, but it can be changed with a command-line option. BIND 8 expects the configuration file to be named /etc/named.conf instead of /etc/named.boot. The db files for our example are in the directory /usr/local/named. Which directory you use does not matter. Avoid putting the directory in the root filesystem if the root filesystem is short on space. Here is the complete version 4 /etc/named.boot file:

; BIND configuration file

directory /usr/local/named

primary  movie.edu                db.movie
primary  249.249.192.in-addr.arpa db.192.249.249
primary  253.253.192.in-addr.arpa db.192.253.253
primary  0.0.127.in-addr.arpa     db.127.0.0
cache    .                        db.cache

Here is the complete version 8 /etc/named.conf file:

// BIND configuration file

options {
        directory "/usr/local/named";
        // Place additional options here.
};

zone "movie.edu" in {
        type master;
        file "db.movie";
};

zone "249.249.192.in-addr.arpa" in {
        type master;
        file "db.192.249.249";
};

zone "253.253.192.in-addr.arpa" in {
        type master;
        file "db.192.253.253";
};

zone "0.0.127.in-addr.arpa" in {
        type master;
        file "db.127.0.0";
};

zone "." in {
        type hint;
        file "db.cache";
};


Previous: 4.2 Setting Up DNS DataDNS & BINDNext: 4.4 Abbreviations
4.2 Setting Up DNS DataBook Index4.4 Abbreviations