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