Updated: October 28, 2024 |
Resolver configuration file
/etc/resolv.conf
The resolver library routines provide access to the Internet Domain Name System (DNS). 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:
Overriding /etc/resolv.conf
You can use the following confstr() configuration strings to override the data contained in /etc/resolv.conf:
my.domain
For example:
nameserver_209.226.137.53
The socket library uses the following search order to locate the resolver data:
Utilities such as dhclient and pppd can optionally set the configuration strings.
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
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
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.
search
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 are attempted using each component of the search path in turn until a match is found.
The search list is currently limited to six domains with a total of 256 characters.
nocache
By default, the resolv.conf data is parsed at application startup only. It is not checked again. Specifying nocache on will cause the resolv.conf data to be parsed at every lookup. If you wish to invalidate the cache at a specific time, it would be better to call res_init() directly, or turn off the _res.options flag RES_INIT.
For more information, see: