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