Configuring the Order in Which a Resolver Uses DNS, /etc/hosts, and NIS

Configuring the Order in Which a Resolver Uses DNS, etc hosts, and NIS

9.7.1 Problem

You want to configure the order in which a system's resolver consults various naming services.

9.7.2 Solution

Some vendor's BIND resolvers support configuration of the order in which the resolvers look up names using the various naming services they support. These naming services may include DNS, NIS, NIS+ and /etc/hosts. On the Solaris and HP-UX operating systems, as well as recent versions of Linux and Irix, resolver service order is configured using the nsswitch.conf file, which usually resides in the /etc directory. Lines in nsswitch.conf begin with the name of a database, followed by a colon and a list of one or more sources. For the resolver, the database name is hosts, and the possible sources are:


The name servers listed in resolv.conf




Sun's Network Information Service


Sun's NIS+

The resolver tries the sources in the order listed, so to tell the resolver to check /etc/hosts before querying a name server, you could add this line to nsswitch.conf:

hosts: files dns

By default, the resolver continues to the next source if the previous isn't available or can't find a name. You can modify this behavior by adding condition=action clauses between source names. The possible conditions are:


True if the previous source hasn't been configured (for example, for DNS, there's no local name server running and no resolv.conf file).


True if a lookup using the previous source returns an answer that indicates that the name doesn't exist.


True if a lookup using the previous source indicates a temporary failure (for example, a DNS query timeout).


True if a lookup using the previous source succeeds.

The supported actions are either return (return the result from the previous source) or continue (go on to the next source). The clause is written in square brackets:

hosts: files [notfound=continue] dns

On Windows 95, 98, and ME, you can configure resolver service order by adding subkeys to the following Registry key:


The four Registry subkeys, each a signed, 16-bit number in hexadecimal format, control the order in which the Windows resolver uses the HOSTS and LMHOSTS files, name servers, and NBT queries to resolve names:


The LMHOSTS file, default priority 499


The HOSTS file, default priority 500


The configured name servers, default priority 2000


NBT queries, default priority 2001

The lower the value of the key, the earlier the resolver uses that naming service. Deleting a subkey prevents the resolver from using the corresponding service.

9.7.3 Discussion

Some older versions of Linux support configuration of the service order using a file called host.conf; try man host.conf to see if your version does.

The only support in Windows NT 4.0 and Windows 2000 for configuring the service order is a single Registry key:


The default value, 0, tells the resolver to query name servers before using NBT queries. Set the value to 1 to instruct the resolver to use NBT queries first.

9.7.4 See Also

"Vendor-Specific Options" in Chapter 6 of DNS and BIND.

Getting Started

Zone Data

BIND Name Server Configuration

Electronic Mail

BIND Name Server Operations

Delegation and Registration


Interoperability and Upgrading

Resolvers and Programming

Logging and Troubleshooting


DNS & BIND Cookbook
DNS & BIND Cookbook
ISBN: 0596004109
EAN: 2147483647
Year: 2005
Pages: 220
Authors: Cricket Liu © 2008-2020.
If you may any questions please contact us: