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 hostname "_localdnsstub" is resolved to the IP address
100           127.0.0.53, i.e. the address the local DNS stub (see above) is
101           listening on.
102
103       •   The hostname "_localdnsproxy" is resolved to the IP address
104           127.0.0.54, i.e. the address the local DNS proxy (see above) is
105           listening on.
106
107       •   The mappings defined in /etc/hosts are resolved to their configured
108           addresses and back, but they will not affect lookups for
109           non-address types (like MX). Support for /etc/hosts may be disabled
110           with ReadEtcHosts=no, see resolved.conf(5).
111

PROTOCOLS AND ROUTING

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

COMPATIBILITY WITH THE TRADITIONAL GLIBC STUB RESOLVER

232       This section provides a short summary of differences in the resolver
233       implemented by nss-resolve(8) together with systemd-resolved and the
234       traditional stub resolver implemented in nss-dns.
235
236       •   Some names are always resolved internally (see Synthetic Records
237           above). Traditionally they would be resolved by nss-files if
238           provided in /etc/hosts. But note that the details of how a query is
239           constructed are under the control of the client library.  nss-dns
240           will first try to resolve names using search domains and even if
241           those queries are routed to systemd-resolved, it will send them out
242           over the network using the usual rules for multi-label name routing
243           [3].
244
245       •   Single-label names are not resolved for A and AAAA records using
246           unicast DNS (unless overridden with ResolveUnicastSingleLabel=, see
247           resolved.conf(5)). This is similar to the no-tld-query option being
248           set in resolv.conf(5).
249
250       •   Search domains are not used for suffixing of multi-label names.
251           (Search domains are nevertheless used for lookup routing, for names
252           that were originally specified as single-label or multi-label.) Any
253           name with at least one dot is always interpreted as a FQDN.
254           nss-dns would resolve names both as relative (using search domains)
255           and absolute FQDN names. Some names would be resolved as relative
256           first, and after that query has failed, as absolute, while other
257           names would be resolved in opposite order. The ndots option in
258           /etc/resolv.conf was used to control how many dots the name needs
259           to have to be resolved as relative first. This stub resolver does
260           not implement this at all: multi-label names are only resolved as
261           FQDNs.[4]
262
263       •   This resolver has a notion of the special ".local" domain used for
264           MulticastDNS, and will not route queries with that suffix to
265           unicast DNS servers unless explicitly configured, see above. Also,
266           reverse lookups for link-local addresses are not sent to unicast
267           DNS servers.
268
269       •   This resolver reads and caches /etc/hosts internally. (In other
270           words, nss-resolve replaces nss-files in addition to nss-dns).
271           Entries in /etc/hosts have highest priority.
272
273       •   This resolver also implements LLMNR and MulticastDNS in addition to
274           the classic unicast DNS protocol, and will resolve single-label
275           names using LLMNR (when enabled) and names ending in ".local" using
276           MulticastDNS (when enabled).
277
278       •   Environment variables $LOCALDOMAIN and $RES_OPTIONS described in
279           resolv.conf(5) are not supported currently.
280
281       •   The nss-dns resolver maintains little state between subsequent DNS
282           queries, and for each query always talks to the first listed DNS
283           server from /etc/resolv.conf first, and on failure continues with
284           the next until reaching the end of the list which is when the query
285           fails. The resolver in systemd-resolved.service however maintains
286           state, and will continuously talk to the same server for all
287           queries on a particular lookup scope until some form of error is
288           seen at which point it switches to the next, and then continuously
289           stays with it for all queries on the scope until the next failure,
290           and so on, eventually returning to the first configured server.
291           This is done to optimize lookup times, in particular given that the
292           resolver typically must first probe server feature sets when
293           talking to a server, which is time consuming. This different
294           behaviour implies that listed DNS servers per lookup scope must be
295           equivalent in the zones they serve, so that sending a query to one
296           of them will yield the same results as sending it to another
297           configured DNS server.
298

/ETC/RESOLV.CONF

300       Four modes of handling /etc/resolv.conf (see resolv.conf(5)) are
301       supported:
302
303systemd-resolved maintains the
304           /run/systemd/resolve/stub-resolv.conf file for compatibility with
305           traditional Linux programs. This file lists the 127.0.0.53 DNS stub
306           (see above) as the only DNS server. It also contains a list of
307           search domains that are in use by systemd-resolved. The list of
308           search domains is always kept up-to-date. Note that
309           /run/systemd/resolve/stub-resolv.conf should not be used directly
310           by applications, but only through a symlink from /etc/resolv.conf.
311           This file may be symlinked from /etc/resolv.conf in order to
312           connect all local clients that bypass local DNS APIs to
313           systemd-resolved with correct search domains settings. This mode of
314           operation is recommended.
315
316       •   A static file /usr/lib/systemd/resolv.conf is provided that lists
317           the 127.0.0.53 DNS stub (see above) as only DNS server. This file
318           may be symlinked from /etc/resolv.conf in order to connect all
319           local clients that bypass local DNS APIs to systemd-resolved. This
320           file does not contain any search domains.
321
322systemd-resolved maintains the /run/systemd/resolve/resolv.conf
323           file for compatibility with traditional Linux programs. This file
324           may be symlinked from /etc/resolv.conf and is always kept
325           up-to-date, containing information about all known DNS servers.
326           Note the file format's limitations: it does not know a concept of
327           per-interface DNS servers and hence only contains system-wide DNS
328           server definitions. Note that /run/systemd/resolve/resolv.conf
329           should not be used directly by applications, but only through a
330           symlink from /etc/resolv.conf. If this mode of operation is used
331           local clients that bypass any local DNS API will also bypass
332           systemd-resolved and will talk directly to the known DNS servers.
333
334       •   Alternatively, /etc/resolv.conf may be managed by other packages,
335           in which case systemd-resolved will read it for DNS configuration
336           data. In this mode of operation systemd-resolved is consumer rather
337           than provider of this configuration file.
338
339       Note that the selected mode of operation for this file is detected
340       fully automatically, depending on whether /etc/resolv.conf is a symlink
341       to /run/systemd/resolve/resolv.conf or lists 127.0.0.53 as DNS server.
342

SIGNALS

344       SIGUSR1
345           Upon reception of the SIGUSR1 process signal systemd-resolved will
346           dump the contents of all DNS resource record caches it maintains,
347           as well as all feature level information it learnt about configured
348           DNS servers into the system logs.
349
350       SIGUSR2
351           Upon reception of the SIGUSR2 process signal systemd-resolved will
352           flush all caches it maintains. Note that it should normally not be
353           necessary to request this explicitly – except for debugging
354           purposes – as systemd-resolved flushes the caches automatically
355           anyway any time the host's network configuration changes. Sending
356           this signal to systemd-resolved is equivalent to the resolvectl
357           flush-caches command, however the latter is recommended since it
358           operates in a synchronous way.
359
360       SIGRTMIN+1
361           Upon reception of the SIGRTMIN+1 process signal systemd-resolved
362           will forget everything it learnt about the configured DNS servers.
363           Specifically any information about server feature support is
364           flushed out, and the server feature probing logic is restarted on
365           the next request, starting with the most fully featured level. Note
366           that it should normally not be necessary to request this explicitly
367           – except for debugging purposes – as systemd-resolved automatically
368           forgets learnt information any time the DNS server configuration
369           changes. Sending this signal to systemd-resolved is equivalent to
370           the resolvectl reset-server-features command, however the latter is
371           recommended since it operates in a synchronous way.
372

CREDENTIALS

374       systemd-resolved supports the service credentials logic as implemented
375       by LoadCredential=/SetCredential= (see systemd.exec(1) for details).
376       The following credentials are used when passed in:
377
378       network.dns, network.search_domains
379           May contain a space separated list of DNS server IP addresses and
380           DNS search domains. This information is only used when no explicit
381           configuration via /etc/systemd/resolved.conf, /etc/resolv.conf or
382           the kernel command line has been provided.
383

KERNEL COMMAND LINE

385       systemd-resolved also honours two kernel command line options:
386
387       nameserver=, domain=
388           Takes the IP address of a DNS server (in case of nameserver=), and
389           a DNS search domain (in case of domain=). May be used multiple
390           times, to define multiple DNS servers/search domains. If either of
391           these options are specified /etc/resolv.conf will not be read and
392           the DNS= and Domains= settings of resolved.conf(5) will be ignored.
393           These two kernel command line options hence override system
394           configuration.
395

IP PORTS

397       The systemd-resolved service listens on the following IP ports:
398
399       •   Port 53 on IPv4 addresses 127.0.0.53 and 127.0.0.54 (both are on
400           the local loopback interface "lo"). This is the local DNS stub, as
401           discussed above. Both UDP and TCP are covered.
402
403       •   Port 5353 on all local addresses, both IPv4 and IPv6 (0.0.0.0 and
404           ::0), for MulticastDNS on UDP. Note that even though the socket is
405           bound to all local interfaces via the selected "wildcard" IP
406           addresses, the incoming datagrams are filtered by the network
407           interface they are coming in on, and separate MulticastDNS
408           link-local scopes are maintained for each, taking into
409           consideration whether MulticastDNS is enabled for the interface or
410           not.
411
412       •   Port 5355 on all local addresses, both IPv4 and IP6 (0.0.0.0 and
413           ::0), for LLMNR, on both TCP and UDP. As with MulticastDNS
414           filtering by incoming network interface is applied.
415

SEE ALSO

417       systemd(1), resolved.conf(5), dnssec-trust-anchors.d(5), nss-
418       resolve(8), resolvectl(1), resolv.conf(5), hosts(5),
419       systemd.network(5), systemd-networkd.service(8)
420

NOTES

422        1. RFC3493
423           https://tools.ietf.org/html/rfc3493
424
425        2. RFC6762
426           https://tools.ietf.org/html/rfc6762
427
428        3. For example, if /etc/resolv.conf has
429
430               nameserver 127.0.0.53
431               search foobar.com barbar.com
432
433
434           and we look up "localhost", nss-dns will send the following queries
435           to systemd-resolved listening on 127.0.0.53:53: first
436           "localhost.foobar.com", then "localhost.barbar.com", and finally
437           "localhost". If (hopefully) the first two queries fail, systemd-
438           resolved will synthesize an answer for the third query.
439
440           When using nss-dns with any search domains, it is thus crucial to
441           always configure nss-files with higher priority and provide
442           mappings for names that should not be resolved using search
443           domains.
444
445        4. There are currently more than 1500 top-level domain names defined,
446           and new ones are added regularly, often using "attractive" names
447           that are also likely to be used locally. Not looking up multi-label
448           names in this fashion avoids fragility in both directions: a valid
449           global name could be obscured by a local name, and resolution of a
450           relative local name could suddenly break when a new top-level
451           domain is created, or when a new subdomain of a top-level domain in
452           registered. Resolving any given name as either relative or absolute
453           avoids this ambiguity.
454
455
456
457
458systemd 253                                        SYSTEMD-RESOLVED.SERVICE(8)
Impressum