]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/systemd-resolved.service.xml
Merge pull request #16678 from poettering/loop-configure
[thirdparty/systemd.git] / man / systemd-resolved.service.xml
CommitLineData
514094f9 1<?xml version='1.0'?>
3a54a157 2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
12b42c76 3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
0307f791 4<!-- SPDX-License-Identifier: LGPL-2.1+ -->
091a364c 5
1ec57f33 6<refentry id="systemd-resolved.service" conditional='ENABLE_RESOLVE'>
091a364c 7
798d3a52
ZJS
8 <refentryinfo>
9 <title>systemd-resolved.service</title>
10 <productname>systemd</productname>
798d3a52
ZJS
11 </refentryinfo>
12
13 <refmeta>
14 <refentrytitle>systemd-resolved.service</refentrytitle>
15 <manvolnum>8</manvolnum>
16 </refmeta>
17
18 <refnamediv>
19 <refname>systemd-resolved.service</refname>
20 <refname>systemd-resolved</refname>
21 <refpurpose>Network Name Resolution manager</refpurpose>
22 </refnamediv>
23
24 <refsynopsisdiv>
25 <para><filename>systemd-resolved.service</filename></para>
12b42c76 26 <para><filename>/usr/lib/systemd/systemd-resolved</filename></para>
798d3a52
ZJS
27 </refsynopsisdiv>
28
29 <refsect1>
30 <title>Description</title>
31
b0fb800c
ZJS
32 <para><command>systemd-resolved</command> is a system service that provides network name resolution to
33 local applications. It implements a caching and validating DNS/DNSSEC stub resolver, as well as an LLMNR
34 and MulticastDNS resolver and responder. Local applications may submit network name resolution requests
35 via three interfaces:</para>
b541146b
LP
36
37 <itemizedlist>
ffd10e5a
ZJS
38 <listitem><para>The native, fully-featured API <command>systemd-resolved</command> exposes on the bus,
39 see
40 <citerefentry><refentrytitle>org.freedesktop.resolve1</refentrytitle><manvolnum>5</manvolnum></citerefentry>
1a0e562a
ZJS
41 and
42 <citerefentry><refentrytitle>org.freedesktop.LogControl1</refentrytitle><manvolnum>5</manvolnum></citerefentry>
ffd10e5a
ZJS
43 for details. Usage of this API is generally recommended to clients as it is asynchronous and fully
44 featured (for example, properly returns DNSSEC validation status and interface scope for addresses as
45 necessary for supporting link-local networking).</para></listitem>
b541146b
LP
46
47 <listitem><para>The glibc
b0fb800c
ZJS
48 <citerefentry project='man-pages'><refentrytitle>getaddrinfo</refentrytitle><manvolnum>3</manvolnum></citerefentry>
49 API as defined by <ulink url="https://tools.ietf.org/html/rfc3493">RFC3493</ulink> and its related
50 resolver functions, including
51 <citerefentry project='man-pages'><refentrytitle>gethostbyname</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
52 This API is widely supported, including beyond the Linux platform. In its current form it does not
53 expose DNSSEC validation status information however, and is synchronous only. This API is backed by the
54 glibc Name Service Switch
55 (<citerefentry project='man-pages'><refentrytitle>nss</refentrytitle><manvolnum>5</manvolnum></citerefentry>).
56 Usage of the glibc NSS module
57 <citerefentry><refentrytitle>nss-resolve</refentrytitle><manvolnum>8</manvolnum></citerefentry> is
38b38500 58 required in order to allow glibc's NSS resolver functions to resolve hostnames via
b541146b
LP
59 <command>systemd-resolved</command>.</para></listitem>
60
b0fb800c
ZJS
61 <listitem><para>Additionally, <command>systemd-resolved</command> provides a local DNS stub listener on
62 IP address 127.0.0.53 on the local loopback interface. Programs issuing DNS requests directly,
63 bypassing any local API may be directed to this stub, in order to connect them to
64 <command>systemd-resolved</command>. Note however that it is strongly recommended that local programs
65 use the glibc NSS or bus APIs instead (as described above), as various network resolution concepts
66 (such as link-local addressing, or LLMNR Unicode domains) cannot be mapped to the unicast DNS
67 protocol.</para></listitem>
b541146b 68 </itemizedlist>
798d3a52 69
b541146b
LP
70 <para>The DNS servers contacted are determined from the global settings in
71 <filename>/etc/systemd/resolved.conf</filename>, the per-link static settings in
6cdf635d 72 <filename>/etc/systemd/network/*.network</filename> files (in case
b0fb800c 73 <citerefentry><refentrytitle>systemd-networkd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
9d569d5f 74 is used), the per-link dynamic settings received over DHCP, information provided via
b0fb800c
ZJS
75 <citerefentry><refentrytitle>resolvectl</refentrytitle><manvolnum>1</manvolnum></citerefentry>, and any
76 DNS server information made available by other system services. See
b541146b 77 <citerefentry><refentrytitle>resolved.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry> and
b0fb800c
ZJS
78 <citerefentry><refentrytitle>systemd.network</refentrytitle><manvolnum>5</manvolnum></citerefentry> for
79 details about systemd's own configuration files for DNS servers. To improve compatibility,
80 <filename>/etc/resolv.conf</filename> is read in order to discover configured system DNS servers, but
81 only if it is not a symlink to <filename>/run/systemd/resolve/stub-resolv.conf</filename>,
82 <filename>/usr/lib/systemd/resolv.conf</filename> or
83 <filename>/run/systemd/resolve/resolv.conf</filename> (see below).</para>
396c716c
LP
84
85 </refsect1>
86
87 <refsect1>
88 <title>Synthetic Records</title>
b541146b 89
b0fb800c
ZJS
90 <para><command>systemd-resolved</command> synthesizes DNS resource records (RRs) for the following
91 cases:</para>
2dc6b11d
LP
92
93 <itemizedlist>
b0fb800c
ZJS
94 <listitem><para>The local, configured hostname is resolved to all locally configured IP addresses
95 ordered by their scope, or — if none are configured — the IPv4 address 127.0.0.2 (which is on the local
96 loopback) and the IPv6 address ::1 (which is the local host).</para></listitem>
97
98 <listitem><para>The hostnames <literal>localhost</literal> and <literal>localhost.localdomain</literal>
99 (as well as any hostname ending in <literal>.localhost</literal> or
100 <literal>.localhost.localdomain</literal>) are resolved to the IP addresses 127.0.0.1 and ::1.
101 </para></listitem>
102
103 <listitem><para>The hostname <literal>_gateway</literal> is resolved to all current default routing
104 gateway addresses, ordered by their metric. This assigns a stable hostname to the current gateway,
105 useful for referencing it independently of the current network configuration state.</para></listitem>
106
107 <listitem><para>The mappings defined in <filename>/etc/hosts</filename> are resolved to their
108 configured addresses and back, but they will not affect lookups for non-address types (like MX).
9d569d5f
ZJS
109 Support for <filename>/etc/hosts</filename> may be disabled with <varname>ReadEtcHosts=no</varname>,
110 see <citerefentry><refentrytitle>resolved.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
b0fb800c 111 </para></listitem>
2dc6b11d 112 </itemizedlist>
396c716c
LP
113 </refsect1>
114
115 <refsect1>
116 <title>Protocols and Routing</title>
2dc6b11d 117
9d569d5f 118 <para>Lookup requests are routed to the available DNS servers, LLMNR, and MulticastDNS interfaces
b0fb800c 119 according to the following rules:</para>
2dc6b11d
LP
120
121 <itemizedlist>
9d569d5f
ZJS
122 <listitem><para>Names for which synthetic records are generated (as listed in the previous section) are
123 never routed to the network and a reply is sent immediately. In particular this means that lookups for
124 <literal>localhost</literal> are never routed to the network.</para></listitem>
125
126 <listitem><para>Single-label names are routed to all local interfaces capable of IP multicasting, where
127 LLMNR is not disabled, using the LLMNR protocol. Lookups for IPv4 addresses are only sent via LLMNR on
128 IPv4, and lookups for IPv6 addresses are only sent via LLMNR on IPv6. Lookups for the locally
129 configured hostname and the <literal>_gateway</literal> hostname are never routed to LLMNR.
130 </para></listitem>
b0fb800c
ZJS
131
132 <listitem><para>Multi-label names with the domain suffix <literal>.local</literal> are routed to all
9d569d5f
ZJS
133 local interfaces capable of IP multicasting, where MulticastDNS is not disabled, using the MulticastDNS
134 protocol. As with LLMNR, IPv4 address lookups are sent via IPv4 and IPv6 address lookups are sent via
135 IPv6.</para></listitem>
136
137 <listitem><para>Resolution of address records (A and AAAA) via unicast DNS (i.e. not LLMNR or
2bd5e1b2
ZJS
138 MulticastDNS) for non-synthesized single-label names is allowed for non-top-level domains. This means
139 that such records can be resolved when search domains are defined. For any interface which defines
140 search domains, such look-ups are routed to that interface, suffixed with each of the search domains
141 defined on that interface in turn. When global search domains are defined, such look-ups are routed to
142 all interfaces, suffixed by each of the global search domains in turn. Additionally, lookup of
143 single-label names via unicast DNS may be enabled with the
144 <varname>ResolveUnicastSingleLabel=yes</varname> setting. The details of which servers are queried and
145 how the final reply is chosen are described below. Note that this means that address queries for
146 single-label names are never sent out to remote DNS servers by default, and if no search domains are
147 defined, resolution will fail.</para></listitem>
b0fb800c
ZJS
148
149 <listitem><para>Other multi-label names are routed to all local interfaces that have a DNS server
9d569d5f
ZJS
150 configured, plus the globally configured DNS servers if there are any. Note that by default, lookups for
151 domains with the <literal>.local</literal> suffix are not routed to DNS servers, unless the domain is
152 specified explicitly as routing or search domain for the DNS server and interface. This means that on
153 networks where the <literal>.local</literal> domain is defined in a site-specific DNS server, explicit
154 search or routing domains need to be configured to make lookups within this DNS domain work. Note that
155 these days, it's generally recommended to avoid defining <literal>.local</literal> in a DNS server, as
156 <ulink url="https://tools.ietf.org/html/rfc6762">RFC6762</ulink> reserves this domain for exclusive
6cdf635d 157 MulticastDNS use.</para></listitem>
9d569d5f
ZJS
158
159 <listitem><para>Address lookups are routed similarly to multi-label names, with the exception that
160 addresses from the link-local address range are never routed to unicast DNS and are only resolved using
161 LLMNR and MulticastDNS (when enabled).</para></listitem>
2dc6b11d
LP
162 </itemizedlist>
163
b0fb800c
ZJS
164 <para>If lookups are routed to multiple interfaces, the first successful response is returned (thus
165 effectively merging the lookup zones on all matching interfaces). If the lookup failed on all interfaces,
166 the last failing response is returned.</para>
2dc6b11d 167
b0fb800c
ZJS
168 <para>Routing of lookups may be influenced by configuring per-interface domain names and other
169 settings. See
2e88625f 170 <citerefentry><refentrytitle>systemd.network</refentrytitle><manvolnum>5</manvolnum></citerefentry> and
b0fb800c
ZJS
171 <citerefentry><refentrytitle>resolvectl</refentrytitle><manvolnum>1</manvolnum></citerefentry> for
172 details. The following query routing logic applies for unicast DNS traffic:</para>
2e88625f
LP
173
174 <itemizedlist>
b0fb800c 175 <listitem><para>If a name to look up matches (that is: is equal to or has as suffix) any of the
9d569d5f
ZJS
176 configured search or route-only domains of any link (see
177 <citerefentry><refentrytitle>systemd.network</refentrytitle><manvolnum>5</manvolnum></citerefentry>),
178 or the globally configured DNS settings (see the discussion of <varname>Domains=</varname> in
179 <citerefentry><refentrytitle>resolved.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>),
b0fb800c
ZJS
180 "best matching" search/route-only domain is determined: the matching one with the most labels. The
181 query is then sent to all DNS servers of any links or the globally configured DNS servers associated
182 with this "best matching" search/route-only domain. (Note that more than one link might have this same
183 "best matching" search/route-only domain configured, in which case the query is sent to all of them in
9d569d5f
ZJS
184 parallel).</para>
185
186 <para>In case of single-label names, when search domains are defined, the same logic applies, except
187 that the name is first suffixed by the search domain.</para></listitem>
b0fb800c
ZJS
188
189 <listitem><para>If a query does not match any configured search/route-only domain (neither per-link nor
190 global), it is sent to all DNS servers that are configured on links with the "DNS default route" option
191 set, as well as the globally configured DNS server.</para></listitem>
192
193 <listitem><para>If there is no link configured as "DNS default route" and no global DNS server
194 configured, the compiled-in fallback DNS server is used.</para></listitem>
195
196 <listitem><para>Otherwise the query is failed as no suitable DNS servers could be determined.
197 </para></listitem>
2e88625f
LP
198 </itemizedlist>
199
b0fb800c
ZJS
200 <para>The "DNS default route" option is a boolean setting configurable with <command>resolvectl</command>
201 or in <filename>.network</filename> files. If not set, it is implicitly determined based on the
202 configured DNS domains for a link: if there's any route-only domain (not matching <literal>~.</literal>)
203 it defaults to false, otherwise to true.</para>
2e88625f 204
9d569d5f
ZJS
205 <para>Effectively this means: in order to support single-label non-synthetized names, define appropriate
206 search domains. In order to preferably route all DNS queries not explicitly matched by search/route-only
207 domain configuration to a specific link, configure a <literal>~.</literal> route-only domain on it. This
208 will ensure that other links will not be considered for these queries (unless they too carry such a
209 route-only domain). In order to route all such DNS queries to a specific link only if no other link
210 is preferable, set the "DNS default route" option for the link to true and do not configure a
211 <literal>~.</literal> route-only domain on it. Finally, in order to ensure that a specific link never
212 receives any DNS traffic not matching any of its configured search/route-only domains, set the "DNS
213 default route" option for it to false.</para>
b0fb800c
ZJS
214
215 <para>See the <ulink url="https://www.freedesktop.org/wiki/Software/systemd/resolved">resolved D-Bus API
216 Documentation</ulink> for information about the APIs <filename>systemd-resolved</filename> provides.
217 </para>
798d3a52
ZJS
218 </refsect1>
219
b541146b
LP
220 <refsect1>
221 <title><filename>/etc/resolv.conf</filename></title>
222
e6b2d948 223 <para>Four modes of handling <filename>/etc/resolv.conf</filename> (see
0a07667d 224 <citerefentry project='man-pages'><refentrytitle>resolv.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>) are
b541146b
LP
225 supported:</para>
226
227 <itemizedlist>
e6b2d948 228 <listitem><para><command>systemd-resolved</command> maintains the
b0fb800c
ZJS
229 <filename>/run/systemd/resolve/stub-resolv.conf</filename> file for compatibility with traditional
230 Linux programs. This file may be symlinked from <filename>/etc/resolv.conf</filename>. This file lists
231 the 127.0.0.53 DNS stub (see above) as the only DNS server. It also contains a list of search domains
232 that are in use by systemd-resolved. The list of search domains is always kept up-to-date. Note that
233 <filename>/run/systemd/resolve/stub-resolv.conf</filename> should not be used directly by applications,
234 but only through a symlink from <filename>/etc/resolv.conf</filename>. This file may be symlinked from
235 <filename>/etc/resolv.conf</filename> in order to connect all local clients that bypass local DNS APIs
236 to <command>systemd-resolved</command> with correct search domains settings. This mode of operation is
e6b2d948
DJL
237 recommended.</para></listitem>
238
b541146b
LP
239 <listitem><para>A static file <filename>/usr/lib/systemd/resolv.conf</filename> is provided that lists
240 the 127.0.0.53 DNS stub (see above) as only DNS server. This file may be symlinked from
b0fb800c
ZJS
241 <filename>/etc/resolv.conf</filename> in order to connect all local clients that bypass local DNS APIs
242 to <command>systemd-resolved</command>. This file does not contain any search domains.
243 </para></listitem>
b541146b
LP
244
245 <listitem><para><command>systemd-resolved</command> maintains the
246 <filename>/run/systemd/resolve/resolv.conf</filename> file for compatibility with traditional Linux
b0fb800c
ZJS
247 programs. This file may be symlinked from <filename>/etc/resolv.conf</filename> and is always kept
248 up-to-date, containing information about all known DNS servers. Note the file format's limitations: it
249 does not know a concept of per-interface DNS servers and hence only contains system-wide DNS server
250 definitions. Note that <filename>/run/systemd/resolve/resolv.conf</filename> should not be used
251 directly by applications, but only through a symlink from <filename>/etc/resolv.conf</filename>. If
252 this mode of operation is used local clients that bypass any local DNS API will also bypass
253 <command>systemd-resolved</command> and will talk directly to the known DNS servers.</para></listitem>
254
255 <listitem><para>Alternatively, <filename>/etc/resolv.conf</filename> may be managed by other packages,
256 in which case <command>systemd-resolved</command> will read it for DNS configuration data. In this mode
257 of operation <command>systemd-resolved</command> is consumer rather than provider of this configuration
b541146b
LP
258 file. </para></listitem>
259 </itemizedlist>
260
b0fb800c
ZJS
261 <para>Note that the selected mode of operation for this file is detected fully automatically, depending
262 on whether <filename>/etc/resolv.conf</filename> is a symlink to
263 <filename>/run/systemd/resolve/resolv.conf</filename> or lists 127.0.0.53 as DNS server.</para>
b541146b
LP
264 </refsect1>
265
2c7284a9
LP
266 <refsect1>
267 <title>Signals</title>
268
269 <variablelist>
270 <varlistentry>
271 <term><constant>SIGUSR1</constant></term>
272
d55b0463 273 <listitem><para>Upon reception of the <constant>SIGUSR1</constant> process signal
b0fb800c
ZJS
274 <command>systemd-resolved</command> will dump the contents of all DNS resource record caches it
275 maintains, as well as all feature level information it learnt about configured DNS servers into the
276 system logs.</para></listitem>
2c7284a9
LP
277 </varlistentry>
278
279 <varlistentry>
280 <term><constant>SIGUSR2</constant></term>
281
d55b0463 282 <listitem><para>Upon reception of the <constant>SIGUSR2</constant> process signal
b0fb800c
ZJS
283 <command>systemd-resolved</command> will flush all caches it maintains. Note that it should normally
284 not be necessary to request this explicitly – except for debugging purposes – as
285 <command>systemd-resolved</command> flushes the caches automatically anyway any time the host's
286 network configuration changes. Sending this signal to <command>systemd-resolved</command> is
287 equivalent to the <command>resolvectl flush-caches</command> command, however the latter is
288 recommended since it operates in a synchronous way.</para></listitem>
d55b0463
LP
289 </varlistentry>
290
291 <varlistentry>
292 <term><constant>SIGRTMIN+1</constant></term>
293
294 <listitem><para>Upon reception of the <constant>SIGRTMIN+1</constant> process signal
295 <command>systemd-resolved</command> will forget everything it learnt about the configured DNS
b0fb800c
ZJS
296 servers. Specifically any information about server feature support is flushed out, and the server
297 feature probing logic is restarted on the next request, starting with the most fully featured
298 level. Note that it should normally not be necessary to request this explicitly – except for
299 debugging purposes – as <command>systemd-resolved</command> automatically forgets learnt information
300 any time the DNS server configuration changes. Sending this signal to
301 <command>systemd-resolved</command> is equivalent to the <command>resolvectl
302 reset-server-features</command> command, however the latter is recommended since it operates in a
303 synchronous way.</para></listitem>
2c7284a9
LP
304 </varlistentry>
305 </variablelist>
d55b0463 306
2c7284a9
LP
307 </refsect1>
308
798d3a52
ZJS
309 <refsect1>
310 <title>See Also</title>
311 <para>
312 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
313 <citerefentry><refentrytitle>resolved.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
b5a8703f 314 <citerefentry><refentrytitle>dnssec-trust-anchors.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
437293cf 315 <citerefentry><refentrytitle>nss-resolve</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
b69f810c 316 <citerefentry><refentrytitle>resolvectl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
1c18f60a 317 <citerefentry project='man-pages'><refentrytitle>resolv.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
394bac4f 318 <citerefentry project='man-pages'><refentrytitle>hosts</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
798d3a52
ZJS
319 <citerefentry><refentrytitle>systemd.network</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
320 <citerefentry><refentrytitle>systemd-networkd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
321 </para>
322 </refsect1>
091a364c
TG
323
324</refentry>