The configuration file's name is /etc/resolv.conf. This file designates the name servers on the network that should be sent queries. The resolver will try to contact a name server on the localhost if it cannot find its configuration file. You should install the configuration file on every host anyway, since this is the only recommended way to specify a system-level default domain, and you can still list the local host's address if it runs a name server. It is considered reasonable to create this file even if you run a local server, since its contents will be cached by each client of the resolver library when the client makes its first call to a resolver routine.
The resolv.conf file contains directives, one per line, of the following forms:
; comment # another comment domain local-domain search search-list nameserver server-address sortlist sort-list options option-list
Exactly one of the domain or search directives should be given, exactly once. If the search directive is given, the first item in the given search-list will override any previously-specified local-domain. The nameserver directive may be given up to three times; additional nameserver directives will be ignored. Comments may be given by starting a line with a ``;'' or ``#''; note that comments were not permitted in versions of the resolver earlier than the one included with BIND 4.9 -- so if your vendor's resolver supports comments, you know they are really on the ball.
The local-domain will be appended to any query-name that does not contain a ``.''. local-domain can be overridden on a per-process basis by setting the LOCALDOMAIN environment variable. Note that local-domain processing can be disabled by setting an option in the resolver.
The search-list is a list of domains which are tried, in order, as qualifying domains for query-names which do not contain a ``.''. Note that search-list processing can be disabled by setting an option in the resolver. Also note that the environment variable ``LOCALDOMAIN'' can override this search-list on a per-process basis.
The server-address's are aggregated and then used as the default destination of queries generated through the resolver. In other words, this is the way you tell the resolver which name servers it should use. It is possible for a given client application to override this list, and this is often done inside the name server (which is itself a resolver client) and in test programs such as nslookup. Note that if you wish to list the local host in your resolver configuration file, you should probably use its primary Internet address rather than a local-host alias such as 127.0.0.1 or 0.0.0.0. This is due to a bug in the handling of connected SOCK_DGRAM sockets in some versions of the BSD networking code. If you must use an address-alias, you should prefer 0.0.0.0 (or simply ``0'') over 127.0.0.1, though be warned that depending on the vintage of your BSD-derived networking code, both of them are capable of failing in their own ways. If your host's IP implementation does not create a short-circuit route between the default interface and the loopback interface, then you might also want to add a static route (eg. in /etc/rc.local) to do so: route add myhost.domain.name localhost 1
The sort-list is a list of IP address, netmask pairs. Addresses returned by gethostbyname are sorted to the order specified by this list. Any addresses that do not match the address netmask pair will be returned after those that do. The netmask is optional and the natural netmask will be used if not specified.
The option-list is a list of options which each override some internal resolver variable. Supported options at this time are:
debug sets the RES_DEBUG bit in _res.options.
ndots:n sets the lower threshold (measured in ``number of dots'') on names given to res_query() such that names with at least this number of dots will be tried as absolute names before any local-domain or search-list processing is done. The default for this internal variable is ``1''.