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 the IP addresses 127.0.0.53 and 127.0.0.54 on the local loopback
39           interface. Programs issuing DNS requests directly, bypassing any
40           local API may be 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 stub resolver on 127.0.0.53 provides the full feature set
48           of the local resolver, which includes offering LLMNR/MulticastDNS
49           resolution. The DNS stub resolver on 127.0.0.54 provides a more
50           limited resolver, that operates in "proxy" mode only, i.e. it will
51           pass most DNS messages relatively unmodified to the current
52           upstream DNS servers and back, but not try to process the messages
53           locally, and hence does not validate DNSSEC, or offer up
54           LLMNR/MulticastDNS. (It will translate to DNS-over-TLS
55           communication if needed however.)
56
57       The DNS servers contacted are determined from the global settings in
58       /etc/systemd/resolved.conf, the per-link static settings in
59       /etc/systemd/network/*.network files (in case systemd-
60       networkd.service(8) is used), the per-link dynamic settings received
61       over DHCP, information provided via resolvectl(1), and any DNS server
62       information made available by other system services. See
63       resolved.conf(5) and systemd.network(5) for details about systemd's own
64       configuration files for DNS servers. To improve compatibility,
65       /etc/resolv.conf is read in order to discover configured system DNS
66       servers, but only if it is not a symlink to
67       /run/systemd/resolve/stub-resolv.conf, /usr/lib/systemd/resolv.conf or
68       /run/systemd/resolve/resolv.conf (see below).
69

SYNTHETIC RECORDS

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

PROTOCOLS AND ROUTING

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

COMPATIBILITY WITH THE TRADITIONAL GLIBC STUB RESOLVER

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

/ETC/RESOLV.CONF

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

SIGNALS

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

SEE ALSO

349       systemd(1), resolved.conf(5), dnssec-trust-anchors.d(5), nss-
350       resolve(8), resolvectl(1), resolv.conf(5), hosts(5),
351       systemd.network(5), systemd-networkd.service(8)
352

NOTES

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