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 vulnerable 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 name servers, 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 a critical 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 local domain name as the search list, the local host as the first name server, and one or two backup name servers. An example of this configuration is:

# Domain name resolver configuration file # search wrotethetutorial.com # try yourself first nameserver 172.16.12.2 # try crab next nameserver 172.16.12.1 # finally try ora nameserver 172.16.1.2

The example is based on our imaginary network, so the default domain name is wrotethetutorial.com. The configuration is for rodent, and it specifies itself as the first name server. The backup servers are crab and ora. 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.

A resolver-only configuration

The resolver-only configuration is very simple. It is identical to the average configuration 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 here:

# Domain name resolver configuration file # search wrotethetutorial.com # try crab nameserver 172.16.12.1 # next try ora nameserver 172.16.1.2

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