1SYSTEMD-RESOLVED.SERVICE(8)systemd-resolved.serviceSYSTEMD-RESOLVED.SERVICE(8)
2
3
4

NAME

6       systemd-resolved.service, systemd-resolved - Network Name Resolution
7       manager
8

SYNOPSIS

10       systemd-resolved.service
11
12       /usr/lib/systemd/systemd-resolved
13

DESCRIPTION

15       systemd-resolved is a system service that provides network name
16       resolution to local applications. It implements a caching and
17       validating DNS/DNSSEC stub resolver, as well as an LLMNR and
18       MulticastDNS resolver and responder. Local applications may submit
19       network name resolution requests via three interfaces:
20
21       •   The native, fully-featured API systemd-resolved exposes on the bus,
22           see org.freedesktop.resolve1(5) and org.freedesktop.LogControl1(5)
23           for details. Usage of this API is generally recommended to clients
24           as it is asynchronous and fully featured (for example, properly
25           returns DNSSEC validation status and interface scope for addresses
26           as necessary for supporting link-local networking).
27
28       •   The glibc getaddrinfo(3) API as defined by RFC3493[1] and its
29           related resolver functions, including gethostbyname(3). This API is
30           widely supported, including beyond the Linux platform. In its
31           current form it does not expose DNSSEC validation status
32           information however, and is synchronous only. This API is backed by
33           the glibc Name Service Switch (nss(5)). Usage of the glibc NSS
34           module nss-resolve(8) is required in order to allow glibc's NSS
35           resolver functions to resolve hostnames via systemd-resolved.
36
37       •   Additionally, systemd-resolved provides a local DNS stub listener
38           on IP address 127.0.0.53 on the local loopback interface. Programs
39           issuing DNS requests directly, bypassing any local API may be
40           directed to this stub, in order to connect them to
41           systemd-resolved. Note however that it is strongly recommended that
42           local programs use the glibc NSS or bus APIs instead (as described
43           above), as various network resolution concepts (such as link-local
44           addressing, or LLMNR Unicode domains) cannot be mapped to the
45           unicast DNS protocol.
46
47       The DNS servers contacted are determined from the global settings in
48       /etc/systemd/resolved.conf, the per-link static settings in
49       /etc/systemd/network/*.network files (in case systemd-
50       networkd.service(8) is used), the per-link dynamic settings received
51       over DHCP, information provided via resolvectl(1), and any DNS server
52       information made available by other system services. See
53       resolved.conf(5) and systemd.network(5) for details about systemd's own
54       configuration files for DNS servers. To improve compatibility,
55       /etc/resolv.conf is read in order to discover configured system DNS
56       servers, but only if it is not a symlink to
57       /run/systemd/resolve/stub-resolv.conf, /usr/lib/systemd/resolv.conf or
58       /run/systemd/resolve/resolv.conf (see below).
59

SYNTHETIC RECORDS

61       systemd-resolved synthesizes DNS resource records (RRs) for the
62       following cases:
63
64       •   The local, configured hostname is resolved to all locally
65           configured IP addresses ordered by their scope, or — if none are
66           configured — the IPv4 address 127.0.0.2 (which is on the local
67           loopback interface) and the IPv6 address ::1 (which is the local
68           host).
69
70       •   The hostnames "localhost" and "localhost.localdomain" as well as
71           any hostname ending in ".localhost" or ".localhost.localdomain" are
72           resolved to the IP addresses 127.0.0.1 and ::1.
73
74       •   The hostname "_gateway" is resolved to all current default routing
75           gateway addresses, ordered by their metric. This assigns a stable
76           hostname to the current gateway, useful for referencing it
77           independently of the current network configuration state.
78
79       •   The hostname "_outbound" is resolved to the local IPv4 and IPv6
80           addresses that are most likely used for communication with other
81           hosts. This is determined by requesting a routing decision to the
82           configured default gateways from the kernel and then using the
83           local IP addresses selected by this decision. This hostname is only
84           available if there is at least one local default gateway
85           configured. This assigns a stable hostname to the local outbound IP
86           addresses, useful for referencing them independently of the current
87           network configuration state.
88
89       •   The mappings defined in /etc/hosts are resolved to their configured
90           addresses and back, but they will not affect lookups for
91           non-address types (like MX). Support for /etc/hosts may be disabled
92           with ReadEtcHosts=no, see resolved.conf(5).
93

PROTOCOLS AND ROUTING

95       The lookup requests that systemd-resolved.service receives are routed
96       to the available DNS servers, LLMNR, and MulticastDNS interfaces
97       according to the following rules:
98
99       •   Names for which synthetic records are generated (the local
100           hostname, "localhost" and "localdomain", local gateway, as listed
101           in the previous section) and addresses configured in /etc/hosts are
102           never routed to the network and a reply is sent immediately.
103
104       •   Single-label names are resolved using LLMNR on all local interfaces
105           where LLMNR is enabled. Lookups for IPv4 addresses are only sent
106           via LLMNR on IPv4, and lookups for IPv6 addresses are only sent via
107           LLMNR on IPv6. Note that lookups for single-label synthesized names
108           are not routed to LLMNR, MulticastDNS or unicast DNS.
109
110       •   Queries for the address records (A and AAAA) of single-label
111           non-synthesized names are resolved via unicast DNS using search
112           domains. For any interface which defines search domains, such
113           look-ups are routed to the servers defined for that interface,
114           suffixed with each of those search domains. When global search
115           domains are defined, such look-ups are routed to the global
116           servers. For each search domain, queries are performed by suffixing
117           the name with each of the search domains in turn. Additionally,
118           lookup of single-label names via unicast DNS may be enabled with
119           the ResolveUnicastSingleLabel=yes setting. The details of which
120           servers are queried and how the final reply is chosen are described
121           below. Note that this means that address queries for single-label
122           names are never sent out to remote DNS servers by default, and
123           resolution is only possible if search domains are defined.
124
125       •   Multi-label names with the domain suffix ".local" are resolved
126           using MulticastDNS on all local interfaces where MulticastDNS is
127           enabled. As with LLMNR, IPv4 address lookups are sent via IPv4 and
128           IPv6 address lookups are sent via IPv6.
129
130       •   Queries for multi-label names are routed via unicast DNS on local
131           interfaces that have a DNS server configured, plus the globally
132           configured DNS servers if there are any. Which interfaces are used
133           is determined by the routing logic based on search and route-only
134           domains, described below. Note that by default, lookups for domains
135           with the ".local" suffix are not routed to DNS servers, unless the
136           domain is specified explicitly as routing or search domain for the
137           DNS server and interface. This means that on networks where the
138           ".local" domain is defined in a site-specific DNS server, explicit
139           search or routing domains need to be configured to make lookups
140           work within this DNS domain. Note that these days, it's generally
141           recommended to avoid defining ".local" in a DNS server, as
142           RFC6762[2] reserves this domain for exclusive MulticastDNS use.
143
144       •   Address lookups (reverse lookups) are routed similarly to
145           multi-label names, with the exception that addresses from the
146           link-local address range are never routed to unicast DNS and are
147           only resolved using LLMNR and MulticastDNS (when enabled).
148
149       If lookups are routed to multiple interfaces, the first successful
150       response is returned (thus effectively merging the lookup zones on all
151       matching interfaces). If the lookup failed on all interfaces, the last
152       failing response is returned.
153
154       Routing of lookups is determined by the per-interface routing domains
155       (search and route-only) and global search domains. See
156       systemd.network(5) and resolvectl(1) for a description how those
157       settings are set dynamically and the discussion of Domains= in
158       resolved.conf(5) for a description of globally configured DNS settings.
159
160       The following query routing logic applies for unicast DNS lookups
161       initiated by systemd-resolved.service:
162
163       •   If a name to look up matches (that is: is equal to or has as
164           suffix) any of the configured routing domains (search or
165           route-only) of any link, or the globally configured DNS settings,
166           "best matching" routing domain is determined: the matching one with
167           the most labels. The query is then sent to all DNS servers of any
168           links or the globally configured DNS servers associated with this
169           "best matching" routing domain. (Note that more than one link might
170           have this same "best matching" routing domain configured, in which
171           case the query is sent to all of them in parallel).
172
173           In case of single-label names, when search domains are defined, the
174           same logic applies, except that the name is first suffixed by each
175           of the search domains in turn. Note that this search logic doesn't
176           apply to any names with at least one dot. Also see the discussion
177           about compatibility with the traditional glibc resolver below.
178
179       •   If a query does not match any configured routing domain (either
180           per-link or global), it is sent to all DNS servers that are
181           configured on links with the DefaultRoute= option set, as well as
182           the globally configured DNS server.
183
184       •   If there is no link configured as DefaultRoute= and no global DNS
185           server configured, one of the compiled-in fallback DNS servers is
186           used.
187
188       •   Otherwise the unicast DNS query fails, as no suitable DNS servers
189           can be determined.
190
191       The DefaultRoute= option is a boolean setting configurable with
192       resolvectl or in .network files. If not set, it is implicitly
193       determined based on the configured DNS domains for a link: if there's a
194       route-only domain other than "~.", it defaults to false, otherwise to
195       true.
196
197       Effectively this means: in order to support single-label
198       non-synthesized names, define appropriate search domains. In order to
199       preferably route all DNS queries not explicitly matched by routing
200       domain configuration to a specific link, configure a "~."  route-only
201       domain on it. This will ensure that other links will not be considered
202       for these queries (unless they too carry such a routing domain). In
203       order to route all such DNS queries to a specific link only if no other
204       link is preferred, set the DefaultRoute= option for the link to true
205       and do not configure a "~."  route-only domain on it. Finally, in order
206       to ensure that a specific link never receives any DNS traffic not
207       matching any of its configured routing domains, set the DefaultRoute=
208       option for it to false.
209
210       See org.freedesktop.resolve1(5) for information about the D-Bus APIs
211       systemd-resolved provides.
212

COMPATIBILITY WITH THE TRADITIONAL GLIBC STUB RESOLVER

214       This section provides a short summary of differences in the stub
215       resolver implemented by nss-resolve(8) together with systemd-resolved
216       and the traditional stub resolver implemented in nss-dns.
217
218       •   Some names are always resolved internally (see Synthetic Records
219           above). Traditionally they would be resolved by nss-files if
220           provided in /etc/hosts. But note that the details of how a query is
221           constructed are under the control of the client library.  nss-dns
222           will first try to resolve names using search domains and even if
223           those queries are routed to systemd-resolved, it will send them out
224           over the network using the usual rules for multi-label name routing
225           [3].
226
227       •   Single-label names are not resolved for A and AAAA records using
228           unicast DNS (unless overridden with ResolveUnicastSingleLabel=, see
229           resolved.conf(5)). This is similar to the no-tld-query option being
230           set in resolv.conf(5).
231
232       •   Search domains are not used for suffixing of multi-label names.
233           (Search domains are nevertheless used for lookup routing, for names
234           that were originally specified as single-label or multi-label.) Any
235           name with at least one dot is always interpreted as a FQDN.
236           nss-dns would resolve names both as relative (using search domains)
237           and absolute FQDN names. Some names would be resolved as relative
238           first, and after that query has failed, as absolute, while other
239           names would be resolved in opposite order. The ndots option in
240           /etc/resolv.conf was used to control how many dots the name needs
241           to have to be resolved as relative first. This stub resolver does
242           not implement this at all: multi-label names are only resolved as
243           FQDNs.[4]
244
245       •   This resolver has a notion of the special ".local" domain used for
246           MulticastDNS, and will not route queries with that suffix to
247           unicast DNS servers unless explicitly configured, see above. Also,
248           reverse lookups for link-local addresses are not sent to unicast
249           DNS servers.
250
251       •   This resolver reads and caches /etc/hosts internally. (In other
252           words, nss-resolve replaces nss-files in addition to nss-dns).
253           Entries in /etc/hosts have highest priority.
254
255       •   This resolver also implements LLMNR and MulticastDNS in addition to
256           the classic unicast DNS protocol, and will resolve single-label
257           names using LLMNR (when enabled) and names ending in ".local" using
258           MulticastDNS (when enabled).
259
260       •   Environment variables $LOCALDOMAIN and $RES_OPTIONS described in
261           resolv.conf(5) are not supported currently.
262

/ETC/RESOLV.CONF

264       Four modes of handling /etc/resolv.conf (see resolv.conf(5)) are
265       supported:
266
267systemd-resolved maintains the
268           /run/systemd/resolve/stub-resolv.conf file for compatibility with
269           traditional Linux programs. This file may be symlinked from
270           /etc/resolv.conf. This file lists the 127.0.0.53 DNS stub (see
271           above) as the only DNS server. It also contains a list of search
272           domains that are in use by systemd-resolved. The list of search
273           domains is always kept up-to-date. Note that
274           /run/systemd/resolve/stub-resolv.conf should not be used directly
275           by applications, but only through a symlink from /etc/resolv.conf.
276           This file may be symlinked from /etc/resolv.conf in order to
277           connect all local clients that bypass local DNS APIs to
278           systemd-resolved with correct search domains settings. This mode of
279           operation is recommended.
280
281       •   A static file /usr/lib/systemd/resolv.conf is provided that lists
282           the 127.0.0.53 DNS stub (see above) as only DNS server. This file
283           may be symlinked from /etc/resolv.conf in order to connect all
284           local clients that bypass local DNS APIs to systemd-resolved. This
285           file does not contain any search domains.
286
287systemd-resolved maintains the /run/systemd/resolve/resolv.conf
288           file for compatibility with traditional Linux programs. This file
289           may be symlinked from /etc/resolv.conf and is always kept
290           up-to-date, containing information about all known DNS servers.
291           Note the file format's limitations: it does not know a concept of
292           per-interface DNS servers and hence only contains system-wide DNS
293           server definitions. Note that /run/systemd/resolve/resolv.conf
294           should not be used directly by applications, but only through a
295           symlink from /etc/resolv.conf. If this mode of operation is used
296           local clients that bypass any local DNS API will also bypass
297           systemd-resolved and will talk directly to the known DNS servers.
298
299       •   Alternatively, /etc/resolv.conf may be managed by other packages,
300           in which case systemd-resolved will read it for DNS configuration
301           data. In this mode of operation systemd-resolved is consumer rather
302           than provider of this configuration file.
303
304       Note that the selected mode of operation for this file is detected
305       fully automatically, depending on whether /etc/resolv.conf is a symlink
306       to /run/systemd/resolve/resolv.conf or lists 127.0.0.53 as DNS server.
307

SIGNALS

309       SIGUSR1
310           Upon reception of the SIGUSR1 process signal systemd-resolved will
311           dump the contents of all DNS resource record caches it maintains,
312           as well as all feature level information it learnt about configured
313           DNS servers into the system logs.
314
315       SIGUSR2
316           Upon reception of the SIGUSR2 process signal systemd-resolved will
317           flush all caches it maintains. Note that it should normally not be
318           necessary to request this explicitly – except for debugging
319           purposes – as systemd-resolved flushes the caches automatically
320           anyway any time the host's network configuration changes. Sending
321           this signal to systemd-resolved is equivalent to the resolvectl
322           flush-caches command, however the latter is recommended since it
323           operates in a synchronous way.
324
325       SIGRTMIN+1
326           Upon reception of the SIGRTMIN+1 process signal systemd-resolved
327           will forget everything it learnt about the configured DNS servers.
328           Specifically any information about server feature support is
329           flushed out, and the server feature probing logic is restarted on
330           the next request, starting with the most fully featured level. Note
331           that it should normally not be necessary to request this explicitly
332           – except for debugging purposes – as systemd-resolved automatically
333           forgets learnt information any time the DNS server configuration
334           changes. Sending this signal to systemd-resolved is equivalent to
335           the resolvectl reset-server-features command, however the latter is
336           recommended since it operates in a synchronous way.
337

SEE ALSO

339       systemd(1), resolved.conf(5), dnssec-trust-anchors.d(5), nss-
340       resolve(8), resolvectl(1), resolv.conf(5), hosts(5),
341       systemd.network(5), systemd-networkd.service(8)
342

NOTES

344        1. RFC3493
345           https://tools.ietf.org/html/rfc3493
346
347        2. RFC6762
348           https://tools.ietf.org/html/rfc6762
349
350        3. For example, if /etc/resolv.conf has
351
352               nameserver 127.0.0.53
353               search foobar.com barbar.com
354
355
356           and we look up "localhost", nss-dns will send the following queries
357           to systemd-resolved listening on 127.0.0.53:53: first
358           "localhost.foobar.com", then "localhost.barbar.com", and finally
359           "localhost". If (hopefully) the first two queries fail, systemd-
360           resolved will synthesize an answer for the third query.
361
362           When using nss-dns with any search domains, it is thus crucial to
363           always configure nss-files with higher priority and provide
364           mappings for names that should not be resolved using search
365           domains.
366
367        4. There are currently more than 1500 top-level domain names defined,
368           and new ones are added regularly, often using "attractive" names
369           that are also likely to be used locally. Not looking up multi-label
370           names in this fashion avoids fragility in both directions: a valid
371           global name could be obscured by a local name, and resolution of a
372           relative local name could suddenly break when a new top-level
373           domain is created, or when a new subdomain of a top-level domain in
374           registered. Resolving any given name as either relative or absolute
375           avoids this ambiguity.
376
377
378
379
380systemd 249                                        SYSTEMD-RESOLVED.SERVICE(8)
Impressum