1.\" Copyright (c) 1986, 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 3. Neither the name of the University nor the names of its contributors 13.\" may be used to endorse or promote products derived from this software 14.\" without specific prior written permission. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26.\" SUCH DAMAGE. 27.\" 28.\" @(#)resolver.5 8.1 (Berkeley) 6/5/93 29.\" $FreeBSD$ 30.\" 31.Dd November 7, 2022 32.Dt RESOLVER 5 33.Os 34.Sh NAME 35.Nm resolver 36.Nd resolver configuration file 37.Sh SYNOPSIS 38.Nm resolv.conf 39.Sh DESCRIPTION 40The 41.Xr resolver 3 42is a set of routines in the C library 43which provide access to the Internet Domain Name System. 44The resolver configuration file contains information that is read 45by the resolver routines the first time they are invoked by a process. 46The file is designed to be human readable and contains a list of 47keywords with values that provide various types of resolver information. 48.Pp 49On a normally configured system this file should not be necessary. 50The only name server to be queried will be on the local machine, 51the domain name is determined from the host name, 52and the domain search path is constructed from the domain name. 53.Pp 54The different configuration options are: 55.Bl -tag -width nameserver 56.It Sy nameserver 57IPv4 or IPv6 address of a name server 58that the resolver should query. 59Up to 60.Dv MAXNS 61(currently 3) name servers may be listed, 62one per keyword. 63If there are multiple servers, 64the resolver library queries them in the order listed. 65If no 66.Sy nameserver 67entries are present, 68the default is to use the name server on the local machine. 69(The algorithm used is to try a name server, and if the query times out, 70try the next, until out of name servers, 71then repeat trying all the name servers 72until a maximum number of retries are made). 73.It Sy domain 74Local domain name. 75Most queries for names within this domain can use short names 76relative to the local domain. 77If no 78.Sy domain 79entry is present, the domain is determined 80from the local host name returned by 81.Xr gethostname 3 ; 82the domain part is taken to be everything after the first 83.Ql \&. . 84Finally, if the host name does not contain a domain part, the root 85domain is assumed. 86.It Sy search 87Search list for host-name lookup. 88The search list is normally determined from the local domain name; 89by default, it contains only the local domain name. 90This may be changed by listing the desired domain search path 91following the 92.Sy search 93keyword with spaces or tabs separating 94the names. 95Most resolver queries will be attempted using each component 96of the search path in turn until a match is found. 97Note that this process may be slow and will generate a lot of network 98traffic if the servers for the listed domains are not local, 99and that queries will time out if no server is available 100for one of the domains. 101.Pp 102The search list is currently limited to six domains 103with a total of 256 characters. 104.It Sy sortlist 105Sortlist allows addresses returned by gethostbyname to be sorted. 106A sortlist is specified by IP address netmask pairs. 107If the netmask is not specified, 108it defaults to the historical Class A/B/C netmask of the net; 109this usage is deprecated. 110The IP address 111and network pairs are separated by slashes. 112Up to 10 pairs may 113be specified. 114E.g., 115.Pp 116.Dl "sortlist 10.9.1.0/255.255.240.0 10.9.0.0/255.255.0.0" 117.It Sy options 118Options allows certain internal resolver variables to be modified. 119The syntax is 120.Pp 121\fBoptions\fP \fIoption\fP \fI...\fP 122.Pp 123where 124.Sy option 125is one of the following: 126.Bl -tag -width no_tld_query 127.It Sy debug 128sets 129.Dv RES_DEBUG 130in _res.options. 131.It Sy usevc 132sets 133.Dv RES_USEVC 134to use TCP instead of UDP for queries. 135.It Sy ndots: Ns Ar n 136sets a threshold for the number of dots which must appear in a name given to 137.Fn res_query 138(see 139.Xr resolver 3 ) 140before an 141.Em initial absolute query 142will be made. 143The default for 144.Em n 145is 146.Dq 1 , 147meaning that if there are any dots in a name, the name 148will be tried first as an absolute name before any 149.Em search list 150elements are appended to it. 151.It Sy timeout: Ns Ar n 152sets the initial amount of time the resolver will wait 153for a response from a remote 154name server before retrying the query via a different name server. 155The resolver may wait longer during subsequent retries 156of the current query since an exponential back-off is applied to 157the timeout value. 158Measured in seconds, the default is 159.Dv RES_TIMEOUT , 160the allowed maximum is 161.Dv RES_MAXRETRANS 162(see 163.In resolv.h ) . 164.It Sy attempts: Ns Ar n 165sets the number of times the resolver will send a query to each of 166its name servers 167before giving up and returning an error to the calling application. 168The default is 169.Dv RES_DFLRETRY , 170the allowed maximum is 171.Dv RES_MAXRETRY 172(see 173.In resolv.h ) . 174.It Sy no_tld_query 175tells the resolver not to attempt to resolve a top level domain name, that 176is, a name that contains no dots. 177Use of this option does not prevent 178the resolver from obeying the standard 179.Sy domain 180and 181.Sy search 182rules with the given name. 183.It Sy reload-period: Ns Ar n 184The resolver checks the modification time of 185.Pa /etc/resolv.conf 186every 187.Ar n 188seconds. 189If 190.Pa /etc/resolv.conf 191has changed, it is automatically reloaded. 192The default for 193.Ar n 194is two seconds. 195Setting it to zero disables the file check. 196.El 197.Pp 198Options may also be specified as a space or tab separated list using the 199.Dv RES_OPTIONS 200environment variable. 201.El 202.Pp 203The 204.Sy domain 205and 206.Sy search 207keywords are mutually exclusive. 208If more than one instance of these keywords is present, 209the last instance will override. 210.Pp 211The keyword and value must appear on a single line, and the keyword 212.Pq for example, Sy nameserver 213must start the line. 214The value follows the keyword, separated by white space. 215.Sh FILES 216.Bl -tag -width /etc/resolv.conf -compact 217.It Pa /etc/resolv.conf 218The file 219.Nm resolv.conf 220resides in 221.Pa /etc . 222.El 223.Sh EXAMPLES 224A basic resolv.conf file could be in the following form. 225.Bd -literal -offset indent 226# The domain directive is only necessary, if your local 227# router advertises something like localdomain and you have 228# set up your hostnames via an external domain. 229domain localdomain.tld 230 231# In case you a running a local dns server or caching name server 232# like local-unbound(8) for example. 233nameserver 127.0.0.1 234 235# IP address of the local or ISP name service 236nameserver 192.168.2.1 237 238# Fallback nameservers, in this case these from Google. 239nameserver 8.8.8.8 240nameserver 4.4.4.4 241 242# Attach an OPT pseudo-RR for the EDNS0 extension, 243# as specified in RFC 2671. 244options edns0 245.Ed 246.Sh SEE ALSO 247.Xr gethostbyname 3 , 248.Xr resolver 3 , 249.Xr hostname 7 , 250.Xr resolvconf 8 251.Sh HISTORY 252The 253.Nm resolv.conf 254file format appeared in 255.Bx 4.3 . 256