]>
Commit | Line | Data |
---|---|---|
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 | |
138 | MulticastDNS) for non-synthesized single-label names is only allowed for non-top-level domains. This | |
139 | means that such records can only be resolved when search domains are defined. For any interface which | |
140 | defines search domains, such look-ups are routed to that interface, suffixed with each of the search | |
141 | domains defined on that interface in turn. When global search domains are defined, such look-ups are | |
142 | routed to all interfaces, suffixed by each of the global search domains in turn. The details of which | |
143 | servers are queried and how the final reply is chosen are described below. Note that this means that | |
144 | address queries for single-label names are never sent out to remote DNS servers, and if no search | |
145 | domains are defined, resolution will fail.</para></listitem> | |
b0fb800c ZJS |
146 | |
147 | <listitem><para>Other multi-label names are routed to all local interfaces that have a DNS server | |
9d569d5f ZJS |
148 | configured, plus the globally configured DNS servers if there are any. Note that by default, lookups for |
149 | domains with the <literal>.local</literal> suffix are not routed to DNS servers, unless the domain is | |
150 | specified explicitly as routing or search domain for the DNS server and interface. This means that on | |
151 | networks where the <literal>.local</literal> domain is defined in a site-specific DNS server, explicit | |
152 | search or routing domains need to be configured to make lookups within this DNS domain work. Note that | |
153 | these days, it's generally recommended to avoid defining <literal>.local</literal> in a DNS server, as | |
154 | <ulink url="https://tools.ietf.org/html/rfc6762">RFC6762</ulink> reserves this domain for exclusive | |
6cdf635d | 155 | MulticastDNS use.</para></listitem> |
9d569d5f ZJS |
156 | |
157 | <listitem><para>Address lookups are routed similarly to multi-label names, with the exception that | |
158 | addresses from the link-local address range are never routed to unicast DNS and are only resolved using | |
159 | LLMNR and MulticastDNS (when enabled).</para></listitem> | |
2dc6b11d LP |
160 | </itemizedlist> |
161 | ||
b0fb800c ZJS |
162 | <para>If lookups are routed to multiple interfaces, the first successful response is returned (thus |
163 | effectively merging the lookup zones on all matching interfaces). If the lookup failed on all interfaces, | |
164 | the last failing response is returned.</para> | |
2dc6b11d | 165 | |
b0fb800c ZJS |
166 | <para>Routing of lookups may be influenced by configuring per-interface domain names and other |
167 | settings. See | |
2e88625f | 168 | <citerefentry><refentrytitle>systemd.network</refentrytitle><manvolnum>5</manvolnum></citerefentry> and |
b0fb800c ZJS |
169 | <citerefentry><refentrytitle>resolvectl</refentrytitle><manvolnum>1</manvolnum></citerefentry> for |
170 | details. The following query routing logic applies for unicast DNS traffic:</para> | |
2e88625f LP |
171 | |
172 | <itemizedlist> | |
b0fb800c | 173 | <listitem><para>If a name to look up matches (that is: is equal to or has as suffix) any of the |
9d569d5f ZJS |
174 | configured search or route-only domains of any link (see |
175 | <citerefentry><refentrytitle>systemd.network</refentrytitle><manvolnum>5</manvolnum></citerefentry>), | |
176 | or the globally configured DNS settings (see the discussion of <varname>Domains=</varname> in | |
177 | <citerefentry><refentrytitle>resolved.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>), | |
b0fb800c ZJS |
178 | "best matching" search/route-only domain is determined: the matching one with the most labels. The |
179 | query is then sent to all DNS servers of any links or the globally configured DNS servers associated | |
180 | with this "best matching" search/route-only domain. (Note that more than one link might have this same | |
181 | "best matching" search/route-only domain configured, in which case the query is sent to all of them in | |
9d569d5f ZJS |
182 | parallel).</para> |
183 | ||
184 | <para>In case of single-label names, when search domains are defined, the same logic applies, except | |
185 | that the name is first suffixed by the search domain.</para></listitem> | |
b0fb800c ZJS |
186 | |
187 | <listitem><para>If a query does not match any configured search/route-only domain (neither per-link nor | |
188 | global), it is sent to all DNS servers that are configured on links with the "DNS default route" option | |
189 | set, as well as the globally configured DNS server.</para></listitem> | |
190 | ||
191 | <listitem><para>If there is no link configured as "DNS default route" and no global DNS server | |
192 | configured, the compiled-in fallback DNS server is used.</para></listitem> | |
193 | ||
194 | <listitem><para>Otherwise the query is failed as no suitable DNS servers could be determined. | |
195 | </para></listitem> | |
2e88625f LP |
196 | </itemizedlist> |
197 | ||
b0fb800c ZJS |
198 | <para>The "DNS default route" option is a boolean setting configurable with <command>resolvectl</command> |
199 | or in <filename>.network</filename> files. If not set, it is implicitly determined based on the | |
200 | configured DNS domains for a link: if there's any route-only domain (not matching <literal>~.</literal>) | |
201 | it defaults to false, otherwise to true.</para> | |
2e88625f | 202 | |
9d569d5f ZJS |
203 | <para>Effectively this means: in order to support single-label non-synthetized names, define appropriate |
204 | search domains. In order to preferably route all DNS queries not explicitly matched by search/route-only | |
205 | domain configuration to a specific link, configure a <literal>~.</literal> route-only domain on it. This | |
206 | will ensure that other links will not be considered for these queries (unless they too carry such a | |
207 | route-only domain). In order to route all such DNS queries to a specific link only if no other link | |
208 | is preferable, set the "DNS default route" option for the link to true and do not configure a | |
209 | <literal>~.</literal> route-only domain on it. Finally, in order to ensure that a specific link never | |
210 | receives any DNS traffic not matching any of its configured search/route-only domains, set the "DNS | |
211 | default route" option for it to false.</para> | |
b0fb800c ZJS |
212 | |
213 | <para>See the <ulink url="https://www.freedesktop.org/wiki/Software/systemd/resolved">resolved D-Bus API | |
214 | Documentation</ulink> for information about the APIs <filename>systemd-resolved</filename> provides. | |
215 | </para> | |
798d3a52 ZJS |
216 | </refsect1> |
217 | ||
b541146b LP |
218 | <refsect1> |
219 | <title><filename>/etc/resolv.conf</filename></title> | |
220 | ||
e6b2d948 | 221 | <para>Four modes of handling <filename>/etc/resolv.conf</filename> (see |
0a07667d | 222 | <citerefentry project='man-pages'><refentrytitle>resolv.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>) are |
b541146b LP |
223 | supported:</para> |
224 | ||
225 | <itemizedlist> | |
e6b2d948 | 226 | <listitem><para><command>systemd-resolved</command> maintains the |
b0fb800c ZJS |
227 | <filename>/run/systemd/resolve/stub-resolv.conf</filename> file for compatibility with traditional |
228 | Linux programs. This file may be symlinked from <filename>/etc/resolv.conf</filename>. This file lists | |
229 | the 127.0.0.53 DNS stub (see above) as the only DNS server. It also contains a list of search domains | |
230 | that are in use by systemd-resolved. The list of search domains is always kept up-to-date. Note that | |
231 | <filename>/run/systemd/resolve/stub-resolv.conf</filename> should not be used directly by applications, | |
232 | but only through a symlink from <filename>/etc/resolv.conf</filename>. This file may be symlinked from | |
233 | <filename>/etc/resolv.conf</filename> in order to connect all local clients that bypass local DNS APIs | |
234 | to <command>systemd-resolved</command> with correct search domains settings. This mode of operation is | |
e6b2d948 DJL |
235 | recommended.</para></listitem> |
236 | ||
b541146b LP |
237 | <listitem><para>A static file <filename>/usr/lib/systemd/resolv.conf</filename> is provided that lists |
238 | the 127.0.0.53 DNS stub (see above) as only DNS server. This file may be symlinked from | |
b0fb800c ZJS |
239 | <filename>/etc/resolv.conf</filename> in order to connect all local clients that bypass local DNS APIs |
240 | to <command>systemd-resolved</command>. This file does not contain any search domains. | |
241 | </para></listitem> | |
b541146b LP |
242 | |
243 | <listitem><para><command>systemd-resolved</command> maintains the | |
244 | <filename>/run/systemd/resolve/resolv.conf</filename> file for compatibility with traditional Linux | |
b0fb800c ZJS |
245 | programs. This file may be symlinked from <filename>/etc/resolv.conf</filename> and is always kept |
246 | up-to-date, containing information about all known DNS servers. Note the file format's limitations: it | |
247 | does not know a concept of per-interface DNS servers and hence only contains system-wide DNS server | |
248 | definitions. Note that <filename>/run/systemd/resolve/resolv.conf</filename> should not be used | |
249 | directly by applications, but only through a symlink from <filename>/etc/resolv.conf</filename>. If | |
250 | this mode of operation is used local clients that bypass any local DNS API will also bypass | |
251 | <command>systemd-resolved</command> and will talk directly to the known DNS servers.</para></listitem> | |
252 | ||
253 | <listitem><para>Alternatively, <filename>/etc/resolv.conf</filename> may be managed by other packages, | |
254 | in which case <command>systemd-resolved</command> will read it for DNS configuration data. In this mode | |
255 | of operation <command>systemd-resolved</command> is consumer rather than provider of this configuration | |
b541146b LP |
256 | file. </para></listitem> |
257 | </itemizedlist> | |
258 | ||
b0fb800c ZJS |
259 | <para>Note that the selected mode of operation for this file is detected fully automatically, depending |
260 | on whether <filename>/etc/resolv.conf</filename> is a symlink to | |
261 | <filename>/run/systemd/resolve/resolv.conf</filename> or lists 127.0.0.53 as DNS server.</para> | |
b541146b LP |
262 | </refsect1> |
263 | ||
2c7284a9 LP |
264 | <refsect1> |
265 | <title>Signals</title> | |
266 | ||
267 | <variablelist> | |
268 | <varlistentry> | |
269 | <term><constant>SIGUSR1</constant></term> | |
270 | ||
d55b0463 | 271 | <listitem><para>Upon reception of the <constant>SIGUSR1</constant> process signal |
b0fb800c ZJS |
272 | <command>systemd-resolved</command> will dump the contents of all DNS resource record caches it |
273 | maintains, as well as all feature level information it learnt about configured DNS servers into the | |
274 | system logs.</para></listitem> | |
2c7284a9 LP |
275 | </varlistentry> |
276 | ||
277 | <varlistentry> | |
278 | <term><constant>SIGUSR2</constant></term> | |
279 | ||
d55b0463 | 280 | <listitem><para>Upon reception of the <constant>SIGUSR2</constant> process signal |
b0fb800c ZJS |
281 | <command>systemd-resolved</command> will flush all caches it maintains. Note that it should normally |
282 | not be necessary to request this explicitly – except for debugging purposes – as | |
283 | <command>systemd-resolved</command> flushes the caches automatically anyway any time the host's | |
284 | network configuration changes. Sending this signal to <command>systemd-resolved</command> is | |
285 | equivalent to the <command>resolvectl flush-caches</command> command, however the latter is | |
286 | recommended since it operates in a synchronous way.</para></listitem> | |
d55b0463 LP |
287 | </varlistentry> |
288 | ||
289 | <varlistentry> | |
290 | <term><constant>SIGRTMIN+1</constant></term> | |
291 | ||
292 | <listitem><para>Upon reception of the <constant>SIGRTMIN+1</constant> process signal | |
293 | <command>systemd-resolved</command> will forget everything it learnt about the configured DNS | |
b0fb800c ZJS |
294 | servers. Specifically any information about server feature support is flushed out, and the server |
295 | feature probing logic is restarted on the next request, starting with the most fully featured | |
296 | level. Note that it should normally not be necessary to request this explicitly – except for | |
297 | debugging purposes – as <command>systemd-resolved</command> automatically forgets learnt information | |
298 | any time the DNS server configuration changes. Sending this signal to | |
299 | <command>systemd-resolved</command> is equivalent to the <command>resolvectl | |
300 | reset-server-features</command> command, however the latter is recommended since it operates in a | |
301 | synchronous way.</para></listitem> | |
2c7284a9 LP |
302 | </varlistentry> |
303 | </variablelist> | |
d55b0463 | 304 | |
2c7284a9 LP |
305 | </refsect1> |
306 | ||
798d3a52 ZJS |
307 | <refsect1> |
308 | <title>See Also</title> | |
309 | <para> | |
310 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
311 | <citerefentry><refentrytitle>resolved.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
b5a8703f | 312 | <citerefentry><refentrytitle>dnssec-trust-anchors.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
437293cf | 313 | <citerefentry><refentrytitle>nss-resolve</refentrytitle><manvolnum>8</manvolnum></citerefentry>, |
b69f810c | 314 | <citerefentry><refentrytitle>resolvectl</refentrytitle><manvolnum>1</manvolnum></citerefentry>, |
1c18f60a | 315 | <citerefentry project='man-pages'><refentrytitle>resolv.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
394bac4f | 316 | <citerefentry project='man-pages'><refentrytitle>hosts</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
798d3a52 ZJS |
317 | <citerefentry><refentrytitle>systemd.network</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
318 | <citerefentry><refentrytitle>systemd-networkd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry> | |
319 | </para> | |
320 | </refsect1> | |
091a364c TG |
321 | |
322 | </refentry> |