RESOLVER(5)

NAME
resolver - resolver configuration file

SYNOPSIS
resolv.conf

DESCRIPTION
The resolver(3) is a set of routines in the C library which provide access to the Internet Domain Name System. The resolver configuration file contains information that is read by the resolver routines the first time they are invoked by a process.

The file is read line by line. Anything after a ‘#’ or ‘’; character is considered a comment and discarded. Blank lines are ignored. The first word on each non-blank line is a keyword which determines how the rest of the line is interpreted. Available keywords are:

nameserver address
    IPv4 or IPv6 address of a name server that the resolver should query. Up to MAXNS (currently 3) name servers may be listed on separate lines. If there are multiple servers, the resolver library queries them in the order listed, unless RES_ROTATE is in effect ( See the rotate option below). If no nameserver 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 name
    Set both the local domain name and the search list to name. Most queries for names within this domain can use short names relative to the local domain. If no domain name has been set, it is derived from the local host name returned by gethostname(3); the domain part is taken to be everything after the first ‘’.. Finally, if the host name does not contain a domain part, the root domain is assumed.

search name1 [name2 ...]
    Set the domain search list. Additionally, sets the local domain to name1. 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 are not local, and 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.

sortlist addr1[/plen1] [addr2[/plen2] ...]
    Sort order for query results in the form of a list of addr/mask or addr/plen entries, for instance:

        sortlist 198.51.100.0/24 203.0.113.0/255.255.255.0 2001:db8::/32

    Masks are only supported for IPv4. If the mask or prefix length is omitted, it defaults to historical class-based addressing for IPv4 and to 64 for IPv6.

    Query results that match one of the sort list entries are sorted accordingly and ahead of query results that don't. If multiple results match a single sort list entry, the order is unspecified.

    If multiple sortlist lines are encountered, entries are appended to the list in the order in which they were encountered, up to a maximum of ten.

options
    Options allows certain internal resolver variables to be modified. The following options are supported:

    debug
        Set RES_DEBUG in _res.options.

    usevc
        Set RES_USEVC to use TCP instead of UDP for queries.

    ndots:n
        Set a threshold for the number of dots which must appear in a name given to res_query() (see resolver(3)) before an initial absolute query will be made. The default for n is “1”, meaning that if there are any dots in a name, the name will be tried first as an absolute name before any search list elements are appended to it.

    timeout:n
        Set the initial amount of time the resolver will wait for a response from a remote name server before retrying the query via a different name server. The resolver may wait longer during subsequent retries of the current query since an exponential back-off is applied to the timeout value. Measured in seconds, the default is RES_TIMEOUT, the allowed maximum is RES_MAXRETRANS (see <resolv.h>).

    attempts:n
        Set the number of times the resolver will send a query to each of its name servers before giving up and returning an error to the calling application. The default is RES_DFLRETRY, the allowed maximum is RES_MAXRETRY (see <resolv.h>).

    edns0
        Set RES_USE_EDNS0. Attach an OPT pseudo-RR for the EDNS0 extension, as specified in RFC 2671. This allows the resolver to advertise a larger UDP receive buffer size, permitting responses larger than the original 512-byte limit.

    inet6
        Set RES_USE_INET6. Causes the resolver to look up AAAA records before A records and to map IPv4 responses into IPv6 addresses. The use of this option is discouraged.

    insecure1
        Set RES_INSECURE1. This disables the check that the response was received from the same server to which the query was sent. Use of this option is a security risk and is not recommended.

    insecure2
        Set RES_INSECURE2. This disables the check that the response contains a query matching the one that was sent. Use of this option is a security risk and is not recommended.

    no-check-names
        Set RES_NOCHECKNAME. This disables the check of incoming host names for invalid characters such as underscore, non-ASCII, or control characters.

    no-debug
        Clears RES_DEBUG. See debug above.

    no-rotate
        Clears RES_ROTATE. See rotate below.

    no-tld-query
        Set RES_NOTLDQUERY. This tells the resolver not to attempt to resolve a top level domain name, that is, a name that contains no dots. Use of this option does not prevent the resolver from obeying the standard domain and search rules with the given name.

    rotate
        Set RES_ROTATE. This causes the resolver to round-robin among the configured name servers, distributing the query load instead of always trying the first listed server.

    reload-period:n
        The resolver checks the modification time of /etc/resolv.conf if more than n seconds have elapsed since the last check. If the file has changed, it is automatically reloaded. The default for n is two seconds. Setting it to zero disables the file check.

    Options may also be passed as a space- or tab-separated list in the RES_OPTIONS environment variable. This environment variable is applied after the configuration file has been read.

The domain and search keywords are mutually exclusive. If more than one instance of these keywords is present, the last instance will override all previous instances.

The keyword and value must appear on a single line, and the keyword (for example, nameserver) must start the line. The value follows the keyword, separated by white space.

ENVIRONMENT

LOCALDOMAIN
    If set, overrides the local domain and search list set in the resolver configuration file.

RES_OPTIONS
    If set, its value is split into words and interpreted as resolver options as described for the options keyword in the resolver configuration file.

FILES

/etc/resolv.conf
    resolver configuration file

EXAMPLES

    # Set the local domain to example.com and the search list to
    # example.com, example.net, example.org
    search example.com example.net example.org
    # Set the local domain and search list to example.com,
    # completely overriding the previous line
    domain example.com
    # Use this if you are running a local caching forwarding (or
    # recursing) resolver like local-unbound(8)
    nameserver 127.0.0.1
    # IP address of the local or ISP name service
    nameserver 198.51.100.53
    nameserver 203.0.113.53
    # Enable EDNS0, which tells the name server that we are capable of
    # handling large responses.  This is required for DNSSEC.
    options edns0

SEE ALSO
getaddrinfo(3), gethostbyname(3), gethostname(3), resolver(3), hostname(7), resolvconf(8)

HISTORY
The resolv.conf file format appeared in 4.3BSD.