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 mappings defined in /etc/hosts are resolved to their configured
80           addresses and back, but they will not affect lookups for
81           non-address types (like MX). Support for /etc/hosts may be disabled
82           with ReadEtcHosts=no, see resolved.conf(5).
83

PROTOCOLS AND ROUTING

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

COMPATIBILITY WITH THE TRADITIONAL GLIBC STUB RESOLVER

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

/ETC/RESOLV.CONF

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

SIGNALS

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

SEE ALSO

329       systemd(1), resolved.conf(5), dnssec-trust-anchors.d(5), nss-
330       resolve(8), resolvectl(1), resolv.conf(5), hosts(5),
331       systemd.network(5), systemd-networkd.service(8)
332

NOTES

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