xref: /freebsd/share/man/man5/resolver.5 (revision e7f0f4f9206e8b0f411847b293c7b79eb84f0e51)
1afe61c15SRodney W. Grimes.\" Copyright (c) 1986, 1991, 1993
2afe61c15SRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
3afe61c15SRodney W. Grimes.\"
4afe61c15SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
5afe61c15SRodney W. Grimes.\" modification, are permitted provided that the following conditions
6afe61c15SRodney W. Grimes.\" are met:
7afe61c15SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
8afe61c15SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
9afe61c15SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
10afe61c15SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
11afe61c15SRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
12dda5b397SEitan Adler.\" 3. Neither the name of the University nor the names of its contributors
13afe61c15SRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
14afe61c15SRodney W. Grimes.\"    without specific prior written permission.
15afe61c15SRodney W. Grimes.\"
16afe61c15SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17afe61c15SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18afe61c15SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19afe61c15SRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20afe61c15SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21afe61c15SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22afe61c15SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23afe61c15SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24afe61c15SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25afe61c15SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26afe61c15SRodney W. Grimes.\" SUCH DAMAGE.
27afe61c15SRodney W. Grimes.\"
2806703946SPau Amma.Dd November 23, 2022
29afe61c15SRodney W. Grimes.Dt RESOLVER 5
303d45e180SRuslan Ermilov.Os
31afe61c15SRodney W. Grimes.Sh NAME
32afe61c15SRodney W. Grimes.Nm resolver
33afe61c15SRodney W. Grimes.Nd resolver configuration file
34afe61c15SRodney W. Grimes.Sh SYNOPSIS
35afe61c15SRodney W. Grimes.Nm resolv.conf
36afe61c15SRodney W. Grimes.Sh DESCRIPTION
37afe61c15SRodney W. GrimesThe
38afe61c15SRodney W. Grimes.Xr resolver 3
39afe61c15SRodney W. Grimesis a set of routines in the C library
40afe61c15SRodney W. Grimeswhich provide access to the Internet Domain Name System.
41afe61c15SRodney W. GrimesThe resolver configuration file contains information that is read
42afe61c15SRodney W. Grimesby the resolver routines the first time they are invoked by a process.
43afe61c15SRodney W. GrimesThe file is designed to be human readable and contains a list of
44afe61c15SRodney W. Grimeskeywords with values that provide various types of resolver information.
45afe61c15SRodney W. Grimes.Pp
4606703946SPau AmmaOn a normally configured system, setting this file manually should not
4706703946SPau Ammabe necessary.
48e8261bbaSPau AmmaThe only name server(s) to be queried will be on the local machine
49e8261bbaSPau Ammaor automatically configured using DHCP or a similar mechanism,
50afe61c15SRodney W. Grimesthe domain name is determined from the host name,
51afe61c15SRodney W. Grimesand the domain search path is constructed from the domain name.
52afe61c15SRodney W. Grimes.Pp
53afe61c15SRodney W. GrimesThe different configuration options are:
54afe61c15SRodney W. Grimes.Bl -tag -width nameserver
55afe61c15SRodney W. Grimes.It Sy nameserver
56a23b08cfSCeri DaviesIPv4 or IPv6 address of a name server
57afe61c15SRodney W. Grimesthat the resolver should query.
58afe61c15SRodney W. GrimesUp to
59afe61c15SRodney W. Grimes.Dv MAXNS
60afe61c15SRodney W. Grimes(currently 3) name servers may be listed,
61afe61c15SRodney W. Grimesone per keyword.
62afe61c15SRodney W. GrimesIf there are multiple servers,
63afe61c15SRodney W. Grimesthe resolver library queries them in the order listed.
64afe61c15SRodney W. GrimesIf no
65afe61c15SRodney W. Grimes.Sy nameserver
66afe61c15SRodney W. Grimesentries are present,
67afe61c15SRodney W. Grimesthe default is to use the name server on the local machine.
68afe61c15SRodney W. Grimes(The algorithm used is to try a name server, and if the query times out,
69afe61c15SRodney W. Grimestry the next, until out of name servers,
70afe61c15SRodney W. Grimesthen repeat trying all the name servers
71afe61c15SRodney W. Grimesuntil a maximum number of retries are made).
72afe61c15SRodney W. Grimes.It Sy domain
73afe61c15SRodney W. GrimesLocal domain name.
74afe61c15SRodney W. GrimesMost queries for names within this domain can use short names
75afe61c15SRodney W. Grimesrelative to the local domain.
76afe61c15SRodney W. GrimesIf no
77afe61c15SRodney W. Grimes.Sy domain
78afe61c15SRodney W. Grimesentry is present, the domain is determined
79afe61c15SRodney W. Grimesfrom the local host name returned by
80906c1e27SMike Pritchard.Xr gethostname 3 ;
81bf7f20c2SRuslan Ermilovthe domain part is taken to be everything after the first
82bf7f20c2SRuslan Ermilov.Ql \&. .
83afe61c15SRodney W. GrimesFinally, if the host name does not contain a domain part, the root
84afe61c15SRodney W. Grimesdomain is assumed.
85afe61c15SRodney W. Grimes.It Sy search
86afe61c15SRodney W. GrimesSearch list for host-name lookup.
87afe61c15SRodney W. GrimesThe search list is normally determined from the local domain name;
88bb1b4b3bSPeter Wemmby default, it contains only the local domain name.
89afe61c15SRodney W. GrimesThis may be changed by listing the desired domain search path
90afe61c15SRodney W. Grimesfollowing the
91afe61c15SRodney W. Grimes.Sy search
92afe61c15SRodney W. Grimeskeyword with spaces or tabs separating
93afe61c15SRodney W. Grimesthe names.
94afe61c15SRodney W. GrimesMost resolver queries will be attempted using each component
95afe61c15SRodney W. Grimesof the search path in turn until a match is found.
96afe61c15SRodney W. GrimesNote that this process may be slow and will generate a lot of network
97afe61c15SRodney W. Grimestraffic if the servers for the listed domains are not local,
98afe61c15SRodney W. Grimesand that queries will time out if no server is available
99afe61c15SRodney W. Grimesfor one of the domains.
100afe61c15SRodney W. Grimes.Pp
101afe61c15SRodney W. GrimesThe search list is currently limited to six domains
102afe61c15SRodney W. Grimeswith a total of 256 characters.
103bb1b4b3bSPeter Wemm.It Sy sortlist
104bb1b4b3bSPeter WemmSortlist allows addresses returned by gethostbyname to be sorted.
1051111b49cSSheldon HearnA sortlist is specified by IP address netmask pairs.
10612bd931dSMike KarelsIf the netmask is not specified,
10712bd931dSMike Karelsit defaults to the historical Class A/B/C netmask of the net;
10812bd931dSMike Karelsthis usage is deprecated.
1091111b49cSSheldon HearnThe IP address
11012bd931dSMike Karelsand network pairs are separated by slashes.
1111111b49cSSheldon HearnUp to 10 pairs may
112bb1b4b3bSPeter Wemmbe specified.
113bf7f20c2SRuslan ErmilovE.g.,
114bb1b4b3bSPeter Wemm.Pp
11512bd931dSMike Karels.Dl "sortlist 10.9.1.0/255.255.240.0 10.9.0.0/255.255.0.0"
116bb1b4b3bSPeter Wemm.It Sy options
117bb1b4b3bSPeter WemmOptions allows certain internal resolver variables to be modified.
118bb1b4b3bSPeter WemmThe syntax is
119bb1b4b3bSPeter Wemm.Pp
120a367bd9eSBrian Somers\fBoptions\fP \fIoption\fP \fI...\fP
121bb1b4b3bSPeter Wemm.Pp
122bb1b4b3bSPeter Wemmwhere
123bb1b4b3bSPeter Wemm.Sy option
124bb1b4b3bSPeter Wemmis one of the following:
125a367bd9eSBrian Somers.Bl -tag -width no_tld_query
126bb1b4b3bSPeter Wemm.It Sy debug
127bb1b4b3bSPeter Wemmsets
128a367bd9eSBrian Somers.Dv RES_DEBUG
129bb1b4b3bSPeter Wemmin _res.options.
1308489ecaeSBjoern A. Zeeb.It Sy usevc
1318489ecaeSBjoern A. Zeebsets
1328489ecaeSBjoern A. Zeeb.Dv RES_USEVC
1338489ecaeSBjoern A. Zeebto use TCP instead of UDP for queries.
134a298e0baSMurray Stokely.It Sy ndots : Ns Ar n
135bb1b4b3bSPeter Wemmsets a threshold for the number of dots which must appear in a name given to
136bb1b4b3bSPeter Wemm.Fn res_query
137bb1b4b3bSPeter Wemm(see
138bb1b4b3bSPeter Wemm.Xr resolver 3 )
139bb1b4b3bSPeter Wemmbefore an
140bb1b4b3bSPeter Wemm.Em initial absolute query
1411111b49cSSheldon Hearnwill be made.
1421111b49cSSheldon HearnThe default for
143bb1b4b3bSPeter Wemm.Em n
144bb1b4b3bSPeter Wemmis
145bb1b4b3bSPeter Wemm.Dq 1 ,
146bb1b4b3bSPeter Wemmmeaning that if there are any dots in a name, the name
147bb1b4b3bSPeter Wemmwill be tried first as an absolute name before any
148bb1b4b3bSPeter Wemm.Em search list
149bb1b4b3bSPeter Wemmelements are appended to it.
150a298e0baSMurray Stokely.It Sy timeout : Ns Ar n
1510e168c15SYaroslav Tykhiysets the initial amount of time the resolver will wait
1520e168c15SYaroslav Tykhiyfor a response from a remote
153bf7f20c2SRuslan Ermilovname server before retrying the query via a different name server.
1540e168c15SYaroslav TykhiyThe resolver may wait longer during subsequent retries
1550e168c15SYaroslav Tykhiyof the current query since an exponential back-off is applied to
1560e168c15SYaroslav Tykhiythe timeout value.
157bf7f20c2SRuslan ErmilovMeasured in seconds, the default is
1580e168c15SYaroslav Tykhiy.Dv RES_TIMEOUT ,
1590e168c15SYaroslav Tykhiythe allowed maximum is
1600e168c15SYaroslav Tykhiy.Dv RES_MAXRETRANS
161a298e0baSMurray Stokely(see
162bf7f20c2SRuslan Ermilov.In resolv.h ) .
163a298e0baSMurray Stokely.It Sy attempts : Ns Ar n
1640e168c15SYaroslav Tykhiysets the number of times the resolver will send a query to each of
1650e168c15SYaroslav Tykhiyits name servers
166bf7f20c2SRuslan Ermilovbefore giving up and returning an error to the calling application.
167bf7f20c2SRuslan ErmilovThe default is
1680e168c15SYaroslav Tykhiy.Dv RES_DFLRETRY ,
1690e168c15SYaroslav Tykhiythe allowed maximum is
1700e168c15SYaroslav Tykhiy.Dv RES_MAXRETRY
171a298e0baSMurray Stokely(see
172bf7f20c2SRuslan Ermilov.In resolv.h ) .
173a367bd9eSBrian Somers.It Sy no_tld_query
174a367bd9eSBrian Somerstells the resolver not to attempt to resolve a top level domain name, that
175bf7f20c2SRuslan Ermilovis, a name that contains no dots.
176bf7f20c2SRuslan ErmilovUse of this option does not prevent
177a367bd9eSBrian Somersthe resolver from obeying the standard
178bb1b4b3bSPeter Wemm.Sy domain
179bb1b4b3bSPeter Wemmand
180bb1b4b3bSPeter Wemm.Sy search
181a367bd9eSBrian Somersrules with the given name.
18260b27ebbSEric van Gyzen.It Sy reload-period : Ns Ar n
18360b27ebbSEric van GyzenThe resolver checks the modification time of
18460b27ebbSEric van Gyzen.Pa /etc/resolv.conf
18560b27ebbSEric van Gyzenevery
18660b27ebbSEric van Gyzen.Ar n
18760b27ebbSEric van Gyzenseconds.
18860b27ebbSEric van GyzenIf
18960b27ebbSEric van Gyzen.Pa /etc/resolv.conf
19060b27ebbSEric van Gyzenhas changed, it is automatically reloaded.
19160b27ebbSEric van GyzenThe default for
19260b27ebbSEric van Gyzen.Ar n
19360b27ebbSEric van Gyzenis two seconds.
19460b27ebbSEric van GyzenSetting it to zero disables the file check.
195bb1b4b3bSPeter Wemm.El
196a367bd9eSBrian Somers.Pp
197a367bd9eSBrian SomersOptions may also be specified as a space or tab separated list using the
198a367bd9eSBrian Somers.Dv RES_OPTIONS
199a367bd9eSBrian Somersenvironment variable.
200afe61c15SRodney W. Grimes.El
201afe61c15SRodney W. Grimes.Pp
202afe61c15SRodney W. GrimesThe
203afe61c15SRodney W. Grimes.Sy domain
204afe61c15SRodney W. Grimesand
205afe61c15SRodney W. Grimes.Sy search
206afe61c15SRodney W. Grimeskeywords are mutually exclusive.
207afe61c15SRodney W. GrimesIf more than one instance of these keywords is present,
208afe61c15SRodney W. Grimesthe last instance will override.
209afe61c15SRodney W. Grimes.Pp
210afe61c15SRodney W. GrimesThe keyword and value must appear on a single line, and the keyword
21160b27ebbSEric van Gyzen.Pq for example, Sy nameserver
212bf7f20c2SRuslan Ermilovmust start the line.
213bf7f20c2SRuslan ErmilovThe value follows the keyword, separated by white space.
214afe61c15SRodney W. Grimes.Sh FILES
215afe61c15SRodney W. Grimes.Bl -tag -width /etc/resolv.conf -compact
216afe61c15SRodney W. Grimes.It Pa /etc/resolv.conf
217afe61c15SRodney W. GrimesThe file
218afe61c15SRodney W. Grimes.Nm resolv.conf
219afe61c15SRodney W. Grimesresides in
220afe61c15SRodney W. Grimes.Pa /etc .
221afe61c15SRodney W. Grimes.El
2224d00d772SGordon Bergling.Sh EXAMPLES
2234d00d772SGordon BerglingA basic resolv.conf file could be in the following form.
2244d00d772SGordon Bergling.Bd -literal -offset indent
2254d00d772SGordon Bergling# The domain directive is only necessary, if your local
2264d00d772SGordon Bergling# router advertises something like localdomain and you have
2274d00d772SGordon Bergling# set up your hostnames via an external domain.
2284d00d772SGordon Berglingdomain localdomain.tld
2294d00d772SGordon Bergling
2304d00d772SGordon Bergling# In case you a running a local dns server or caching name server
2314d00d772SGordon Bergling# like local-unbound(8) for example.
2324d00d772SGordon Berglingnameserver 127.0.0.1
2334d00d772SGordon Bergling
2344d00d772SGordon Bergling# IP address of the local or ISP name service
2354d00d772SGordon Berglingnameserver 192.168.2.1
2364d00d772SGordon Bergling
2374d00d772SGordon Bergling# Fallback nameservers, in this case these from Google.
2384d00d772SGordon Berglingnameserver 8.8.8.8
239*e7f0f4f9SPaula Bretonnameserver 8.8.4.4
2404d00d772SGordon Bergling
2414d00d772SGordon Bergling# Attach an OPT pseudo-RR for the EDNS0 extension,
2424d00d772SGordon Bergling# as specified in RFC 2671.
2434d00d772SGordon Berglingoptions edns0
2444d00d772SGordon Bergling.Ed
245afe61c15SRodney W. Grimes.Sh SEE ALSO
246afe61c15SRodney W. Grimes.Xr gethostbyname 3 ,
247afe61c15SRodney W. Grimes.Xr resolver 3 ,
248388bc301SEdward Tomasz Napierala.Xr hostname 7 ,
249388bc301SEdward Tomasz Napierala.Xr resolvconf 8
250afe61c15SRodney W. Grimes.Sh HISTORY
251afe61c15SRodney W. GrimesThe
252afe61c15SRodney W. Grimes.Nm resolv.conf
253afe61c15SRodney W. Grimesfile format appeared in
254afe61c15SRodney W. Grimes.Bx 4.3 .
255