Linux Server How To

How To Setup, Configure, Manage and Secure a Linux Server


Linux Server How To - How to Configure a Caching Nameserver


Named.conf for a Caching Nameserver

A caching nameserver configuration can also serve as the basis for an authoritative name server as the key difference between the two is simply the addition of the zones that the name server will be authoritative for. All DNS servers should be configured to be authoritative for the localhost address 127.0.0.1 as this can alleviate problems caused by client systems with incomplete host files and other configuration issues and adding additional zones that the name server can be authoritative for is remarkably easy. The main configuration file for your BIND DNS server is named.conf and it is usually located in the /etc directory. Specified within named.conf is a working directory that contains the zone files for the zones that the server is authoritative for and the root server cache, a file that specifies the locate of the parent name servers.

Our example /etc/named.conf for a caching nameserver is shown below. Please bear in mind that anything to the right of a // is considered to be a comment and is ignored by named.

options {       // Configuration Options
directory "/var/named";      // Working Directory
forwarders { 203.26.230.21; };      // Forwarding Name Server
};

//
// a caching only nameserver config
//
zone "." IN {       // The file named.root is placed
type hint;       // in the working directory
file "named.root";       // and contains the IP addresses of the parent name servers
};

zone "localhost" IN {       // This zone permits localhost to be resolved to 127.0.0.1
type master;
file "localhost.zone";
allow-update { none; };
};

zone "0.0.127.in-addr.arpa" IN {       // This zone permits a reverse lookup on 127.0.0.1 to resolve to localhost
type master;
file "named.local";
allow-update { none; };
};



Our example caching nameserver named.conf is very straight forward. Among our basic options are the working directory, which we have specified as /var/named. The working directory serves to hold zone files and the root server cache. Specifying the working directory allows you to type the names of the zone files without having to type its complete path. If this directory doesnt exist log in to your Linux server as root and create it.

The only other option we have specified is the address of a forwarder, a name server that our caching nameserver will refer to if it does not have the answer to a query already in its cache before it attempts a recursive lookup. Put the IP address of a DNS server that you wish to use as a forwarder into this section, replacing the IP address we have supplied. If you do not wish to use a forwarder simply delete the entire line from your named.conf.

The /var/named Directory

In our named.conf file we have specified the working directory as /var/named and in our caching example named.conf file we can see reference to three seperate zones, the zone files for which must be in the working directory. We can add futher zones if we wish to do so and this will mean our caching name server will take on the role of an authoritative name server that also caches and performs recursive lookups.

The first zone specified is for the parent name servers, denote by the zone ".". Any DNS server that performs recursive DNS lookups must be aware of the location of the parent nameservers. This is provided by a file that contains the parent nameservers names and IP addresses that is usually called named.root, named.cache, root.hints or root.zone. Download this file if you dont have it as described in How and Where to Download a New named.root and make sure it is present in /var/named with the file name as named.root as specified in our example named.conf.

The other two zones, localhost and 0.0.127.in-addr.arpa are present to allow the localhost IP address 127.0.0.1 to be resolvable. 127.0.0.1 is an important address that is used on many different operating systems and is generally assigned to the each individual computers loopback device. It is highly recommended that all name servers are capable of resolving the loopback address.

named.local looks like this-

$TTL 86400
@ IN SOA localhost. root.localhost. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS localhost.
1 IN PTR localhost.



localhost.zone looks like this-

$TTL 86400
$ORIGIN localhost.
@ 1D   IN SOA @ root (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
1D IN NS @
1D IN A 127.0.0.1