/etc/resolv.conf

resolver configuration file

Name:

/etc/resolv.conf

Description:

The resolver library routines provide access to the Internet Domain Name System. When these routines are first invoked by a process, they read information contained in the resolver configuration file. This file contains a list of keywords with user-specified values that provide various types of resolver information.

This file is optional. If it isn't present, then the only name server to be queried will be on the local machine. Furthermore, the domain name will be determined from the hostname and the domain search path will be constructed from the domain name.

Keywords

The keyword and its associated value must appear on a single line. The line must start with the keyword (e.g. nameserver) followed by whitespace and the value.

The domain and search keywords are mutually exclusive. If more than one instance of these keywords is present, the last instance overrides any others.

nameserver

This is the Internet address (in dot notation) of a name server that the resolver should query. Up to MAXNS (currently 3) name servers may be listed, one per keyword. If multiple server entries are present, the resolver library queries them in the order listed. If no server entries are present, the default is to use the name server on the local machine. (The algorithm used is to try a name server, and if the query times out, try the next, until out of name servers, then repeat trying all the name servers until a maximum number of retries are made).

domain

This is the local domain. Most queries for names within this domain can use short names relative to the local domain. If no domain entry is present, the domain is determined from the local hostname returned by gethostname(); the domain part is taken to be everything after the first dot. If the hostname doesn't contain a domain part, the root domain is assumed.

lookup

This keyword is used by the library routines gethostbyname() and gethostbyname(). It specifies which databases to search, and the search order. The legal space-separated values are:

bind
Use the Domain Name server by querying named.
file
Search for entries in /etc/hosts.

If the lookup keyword isn't used in the system's resolv.conf file, then the assumed order is bind file. If resolv.conf doesn't exist, the only database used is file.

search

This is the search list used for looking up hostnames. The search list is normally determined from the local domain name. By default, it begins with the local domain name, then with successive parent domains that have at least two components in their names.

You can override the default list by specifying the desired domain search path and by following the search keyword with the names. Most resolver queries will be attempted using each component of the search path in turn until a match is found. Note that this process may be slow and will generate a lot of network traffic if the servers for the listed domains aren't local. Note also that queries will time out if no server is available for one of the domains.

The search list is currently limited to six domains with a total of 256 characters.

See also:

gethostname(), dn_comp(), dn_expand(), res_int(), res_mkquery(), res_query(), res_search(), res_send(), /etc/hostname file, named

TCP/IP Network Administration

DNS and BIND by Paul Albitz and Cricket Liu, O'Reilly & Associates (ISBN 1-56592-010-4)