Configuring the Resolver

The resolver is configured in the /etc/resolv.conf file. The resolver is not a separate and distinct process; it is a library of routines called by network processes. The resolv.conf file is read when a process using the resolver starts, and is cached for the life of that process. If the configuration file is not found, the resolver attempts to connect to the named server running on the local host. While this may work, I don't recommend it. By allowing the resolver configuration to default, you give up control over your system and become vunerable to variations in the techniques used by different systems to determine the default configuration. For these reasons, the resolver configuration file should be created on every system running BIND.

The Resolver Configuration File

The configuration file clearly documents the resolver configuration. It allows you to identify up to three nameservers, two of which provide backup if the first server doesn't respond. It defines the default domain and various other processing options. The resolv.conf file is an important part of configuring name service.

resolv.conf is a simple, human-readable file. There are system-specific variations in the commands used in the file, but the entries supported by most systems are:

The most common resolv.conf configuration defines the default domain name, the local host as the first nameserver, and two backup nameservers. An example of this configuration is:

# Domain name resolver configuration file # domain nuts.com # try yourself first nameserver 172.16.12.2 # try almond next nameserver 172.16.12.1 # finally try filbert nameserver 172.16.1.2

The example is based on our imaginary network, so the default domain name is nuts.com. The configuration is for peanut and it specifies itself as the first nameserver. The backup servers are almond and filbert. The configuration does not contain a sort list or any options, as these are infrequently used. This is an example of an average resolver configuration.

resolver-only configuration

The resolver-only configuration is very simple. It is identical to the average configuration shown above except that it does not contain a nameserver entry for the local system. A sample resolv.conf file for a resolver-only system is shown below:

# Domain name resolver configuration file # domain nuts.com # try almond nameserver 172.16.12.1 # next try filbert nameserver 172.16.1.2

The configuration tells the resolver to pass all queries to almond; if that fails, try filbert. Queries are never resolved locally. This simple resolv.conf file is all that is required for a resolver-only configuration.