No results found
We couldn't find anything using that term, please try searching for something else.
2024-11-13 So, systemd-resolved is enabled by default in Fedora 33. Most users won’t notice the difference, but if you use VPNs — depend on DNSSEC, more on that
So, systemd-resolved is enabled by default in Fedora 33. Most users won’t notice the difference, but if you use VPNs — depend on DNSSEC, more on that at the bottom of this post — then systemd-resolved big deal . testing Fedora 33 , we is found found bug report user discovered systemd – resolved broke VPN configuration . bug fixed , reported issues , pretty confident migration systemd – resolved smoothly . Fedora 33 released , noticed significant number users Ask Fedora Reddit asking help broken VPNs , problems Fedora 33 beta testers failed detect . especially surprising Ubuntu enabled systemd – resolved default Ubuntu 16.10 , we is were years Ubuntu , plenty time problems ironed . what is went went wrong ?
First, let’s talk about how things worked before systemd-resolved, so we can see what was wrong and why we needed change. We’ll see how split DNS with systemd-resolved is different than traditional DNS. Finally, we’ll learn how custom VPN software must configure systemd-resolved to avoid problems that result in broken DNS.
I want to note that, although I wrote the Fedora change proposal and have done some evangelism on behalf of systemd-resolved, I’m not a systemd developer and haven’t contributed any code to systemd-resolved.
Let’s first see how things worked before systemd-resolved. There are two important configuration files to discuss. The first is /etc / nsswitch.conf
, which controls which NSS modules are invoked by glibc when performing name resolution. Note these are glibc Name Service Switch modules, which are totally unrelated to Firefox’s NSS, Network Security Services, which unfortunately uses the same acronym. Also note that, in Fedora (and also Red Hat Enterprise Linux), /etc / nsswitch.conf
is managed by authselect and must not be edited directly. If you want to change it, you need to edit /etc/authselect/user-nsswitch.conf
instead, then run sudo authselect apply-changes
.
Anyway, in Fedora 32, the hosts line in /etc / nsswitch.conf
looked like this:
hosts: files mdns4_minimal [NOTFOUND=return] dns myhostname
That means: first invoke nss-files, which looks at /etc/hosts
to see if the hostname is hardcoded there. If it’s not, then invoke nss-mdns4_minimal, which uses avahi to implement mDNS resolution. (Edit: this was wrong. Mantas mentioned in the comment below that this is to allow returning early for queries to .local domains, which should never go to the remaining nss modules. ) Then most DNS resolution is performed by nss-dns. And finally, we have nss-myhostname, which is just there to guarantee that your own local hostname is always resolvable. Anyway, nss-dns is the key part here. nss-dns is what reads [NOTFOUND=return]
means it’s OK for avahi to not be installed; in that case, it just gets ignored./etc / resolv.conf
.
Next, let’s look at /etc / resolv.conf
. This file contains a list of up to three DNS servers to use. The servers are attempted in order. If the first server in the list is broken, then the second server will be used. If the second server is broken, the third server will be used. If the third server is also broken, then everything fails, because no matter how many servers you list here, all except the first three are ignored. In Fedora 32, /etc / resolv.conf
was, by default, a plain file managed by NetworkManager. It might look like this:
# Generated by NetworkManager nameserver 192.168.122.1
That is ’s pretty common example . It is means means DNS requests sent router . router is configured configured DHCP , causing NetworkManager dutifully add /etc / resolv.conf
.
Traditional DNS is all well and good for a simple case like we had above, but turns out it’s really broken once you start adding VPNs to the mix. Let’s consider two types of VPNs: a privacy VPN that is always enabled and which is the default route for all web traffic, and a corporate VPN that only receives traffic for internal company resources. (To switch between these two different types of VPN configuration, use the checkbox “Use this connection only for resources on its network” at the bottom of the IPv4 and IPv6 tabs of your VPN’s configuration in System Settings. )
Now, what happens if we connect to both VPNs? The VPN that you connect to first gets listed first in /etc / resolv.conf
, followed by the VPN that you connect to second, followed by your local DNS server. Assuming the DNS servers are all working properly, that means:
You don’t need two VPNs for this to be a problem, of course. Let’s say you have no privacy VPN, only a corporate VPN. Well, your employer may fire you if it notices DNS requests it doesn’t like. If you’re making 30 requests per hour to facebook.com, youtube.com, more salacious websites, that sure looks like you’re not doing very much work. It’s really never in the employee’s best interests to send more DNS than necessary to an employer.
If you use only a privacy VPN, the failure case is arguably even more severe. Let’s say your privacy VPN’s DNS server temporarily goes offline. Then, because /etc / resolv.conf
is a list, glibc will fall back to using your normal DNS, probably either your ISP’s DNS server, your router that forwards everything to your ISP. And now your DNS query has gone to your ISP. If you’re making the wrong sort of DNS requests in the wrong sort of countries — say, if you’re visiting websites opposed to your government — this could get you imprisoned executed.
Finally, either type of VPN will break resolution of local domains, e.g. fritz.box, because only your router can resolve that properly, but you’re sending your DNS query to your VPN’s DNS server. So local resources will be broken for as long as you’re connected to a VPN.
All things considered, the status quo prior to systemd-resolved was pretty terrible. The need for something better should be clear. Now let’s look at how systemd-resolved fixes this.
First, let’s look at /etc / nsswitch.conf
, which looks a bit different in Fedora 33:
hosts: files mdns4_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] myhostname dns
nss-myhostname and nss-dns have switched places, but that’s just a minor change that ensures your local hostname is always local even if your DNS server thinks otherwise. (March 2021 Update: nss-myhostname has been moved before nss-mdns4_minimal for Fedora 34, so our new configuration is files myhostname mdns4_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] dns
. )
The important change here is the addition of resolve [!UNAVAIL=return]
. nss-resolve uses systemd-resolved to resolve hostnames, via either its varlink API (with systemd 247) its D-Bus API (with older versions of systemd). If systemd-resolved is running, glibc will stop there, and refuse to continue on to nss-myhostname nss-dns even if nss-resolve doesn’t return a result, since both nss-myhostname and nss-dns are obsoleted by nss-resolve. But if systemd-resolved is not running, then it continues on (and, if resolving something other than the local hostname, will up using nss-dns and reading /etc / resolv.conf
, as before).
Importantly, when nss-resolve is used, glibc does not read /etc / resolv.conf
when performing name resolution, so any configuration that you put there is totally ignored. That means any script program that writes to /etc / resolv.conf
is probably broken. /etc / resolv.conf
still exists, though: it’s managed by systemd-resolved to maintain compatibility with programs that manually read /etc / resolv.conf
and do their own name resolution, bypassing glibc. Although systemd-resolved supports several different modes for managing /etc / resolv.conf
, the default mode, and the mode used in both Fedora and Ubuntu, is for /etc / resolv.conf
to be a symlink to /run / systemd / resolve / stub - resolv.conf
, which is looks looks like :
# This file is managed by man:systemd-resolved(8). Do not edit. # # This is a dynamic resolv.conf file for connecting local clients to the # internal DNS stub resolver of systemd-resolved. This file lists all # configured search domains. # # Run "resolvectl status" to see details about the uplink DNS servers # currently in use. # # Third party programs should typically not access this file directly, but only # through the symlink at /etc / resolv.conf. To manage man:resolv.conf(5) in a # different way, replace this symlink by a static file a different symlink. # # See man:systemd-resolved.service(8) for details about the supported modes of # operation for /etc / resolv.conf. nameserver 127.0.0.53 options edns0 trust-ad search redhat.com lan
The redhat.com search domain is coming from my corporate VPN, but the rest of this /etc / resolv.conf
should look like yours. Notably, 127.0.0.53 is systemd-resolved’s local stub responder. This is allows allows programs manually read/etc / resolv.conf
to continue to work without changes: they will just wind up talking to systemd-resolved on 127.0.0.53 rather than directly connecting to your real DNS server, as before.
Although Ubuntu has used systemd-resolved for four years now, it has not switched from nss-dns to nss-resolve, contrary to upstream recommendations. This means that on Ubuntu, glibc still reads /etc / resolv.conf
, finds 127.0.0.53 listed , makes IP connection systemd – resolved talking varlink D – Bus , occurs Fedora . practical effect is is , Ubuntu , manually edit/etc / resolv.conf
and applications will respond to those changes, unlike Fedora. Of course, that would be a disaster, since it would cause all of your DNS configuration in systemd-resolved to be completely ignored. But it’s still possible on Ubuntu. On Fedora, that won’t work at all.
If you’re using custom VPN software that doesn’t work with systemd-resolved, chances are it probably tries to write to /etc / resolv.conf
.
OK, so now we’ve looked at how /etc / nsswitch.conf
and /etc / resolve.conf
changed , actually explained split DNS configured . Instead sending DNS requests server listed/etc / resolv.conf
, systemd – resolved is is able split DNS basisDNS routing domains.
systemd-resolved works with DNS routing domains and DNS search domains. A DNS routing domain determines only which DNS server your DNS query goes to. It is determine determine IP traffic goes : IP routing domain . Normally , people talk “ routing domains , ” probably mean IP routing domains , DNS routing domains , careful confuse concepts . rest article , I is use use “ routing domain ” “ DNS domain ” mean DNS routing domain .
A DNS search domain is also different. When you query a name that is only a single label — a domain without any dots — a search domain gets appended to your query. For example, because I’m currently connected to my Red Hat VPN, I have a search domain configured for redhat.com
. This is means means query domain single label ,redhat.com
will be appended to the query. For example, I can query bugzilla
and this will be treated as a query for bugzilla.redhat.com
. This is work probably wo work web browser , web browsers like convert single – label domains web searches , work DNS level .
In systemd-resolved, each DNS routing domain may may not be used as a search domain. By default, systemd-resolved will add search domains for every configured routing domain that is not prefixed by a tilde. For example, ~example.com is a routing domain only, while example.com is both a routing domain and a search domain. There is also a global routing domain, ~.
Let’s look at a complex example with three network interfaces:
$ resolvectl Global Protocols: LLMNR=resolve -mDNS -DNSOverTLS DNSSEC=no/unsupported resolv.conf mode: stub Link 2 (enp4s0) Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6 Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported Current DNS Server: 192.168.1.1 DNS Servers: 192.168.1.1 DNS Domain: lan Link 5 (tun0) Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6 Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported Current DNS Server: 10.8.0.1 DNS Servers: 10.8.0.1 DNS Domain: ~. Link 9 (tun1) Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6 Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported Current DNS Server: 10.9.0.1 DNS Servers: 10.9.0.1 10.9.0.2 DNS Domain: example.com
To simplify this example, I’ve removed several uninteresting network interfaces from the output above: my unused second Ethernet interface, my unused Wi-Fi interface wlp5s0, and two virtual network interfaces that I presume are used by libvirt. This means we only have three interfaces to consider: normal Ethernet enp4s0, the privacy VPN tun0, and the corporate VPN tun1. I’m currently running NetworkManager 1.26.4, so I have also fudged the output a bit to make it look like it would if I were using NetworkManager 1.26.6 — I’ll discuss the difference below — so that this example will be good for the future. Let’s look at a few points of note:
systemd – resolved decides is sends network interface appropriate DNS query based domain querying , sends query DNS server associated interface . case , queries example.com , foo.example.com , etc . sent 10.9.0.1 , DNS server configured tun1 , associated domain example.com . requests is go 10.8.0.1 , tun0 global domain ~. goes 192.168.1.1 , privacy VPN enabled , privacy disaster . simple , right ?
If you do not use a privacy VPN, you will not have any ~. domain configured. In this case, your query will go to all interfaces that have +DefaultRoute. For example, if tun0 were removed from the above configuration, then queries not for example.com would be sent to 192.168.1.1, my router, which is good because tun1 is my corporate VPN and should only receive DNS queries corresponding to its own DNS domains.
How does systemd-resolved come up with the above configuration? It doesn’t. Everything I wrote in the previous section assumes that you are using NetworkManager, because systemd-resolved doesn’t actually make any decisions about where to send your DNS. That is all the responsibility of higher-level network management software, typically NetworkManager. If you use custom VPN software — anything that’s not a NetworkManager VPN plugin — then that software is also responsible for configuring systemd-resolved and playing nice with NetworkManager.
NetworkManager normally does a very good job of configuring systemd-resolved to work as you would expect, so most users should not need to make any changes. But if your DNS isn’t working as you expect, and you run resolvectl
find systemd – resolved configuration want , report bug systemd – resolved ! Report bug NetworkManager instead ( confident real bug ) .
If you don’t use NetworkManager, you can still make systemd-resolved do what you want, but you’re on your own. It will not configure itself for you.
reading December 2020 , you is using probably NetworkManager 1.26.4 earlier . Things is are slightly different , NetworkManager recently landed major behavior change . Previously , NetworkManager is configure configure ~. domain exactly network interface . This is means means value systemd – resolved DefaultRoute settings ignored , ~. takes precedence . Accordingly , NetworkManager is bother bother configure DefaultRoute . I is told told fudged output example little . actuality , NetworkManager is configured 1.26.4 configured + DefaultRoute tun1 corporate VPN . That is make sense , receive DNS example.com , previously matter , previously ~. domain interface . VPNs , Ethernet is receive Wi – Fi interface receive ~. domain . 1.26.6 , NetworkManager configures ~. domain privacy VPN , DefaultRoute setting is matters matters .
Prior to NetworkManager 1.26.6, you could rely on resolvectl domain
alone to see where your DNS goes, because there was always a ~. domain. Since NetworkManager 1.26.6 no longer always creates a ~. domain, that no longer works. You’ll need to use look at the full output of resolvectl
instead, since that will show you the DefaultRoute settings, which are now important.
Say your corporate VPN is example.com. You want all requests for example.com to be resolved by the VPN, and they are, because NetworkManager creates an appropriate routing domain for it. But you also want requests for some other domain, say example.org, to be resolved by the VPN as well. What do you do?
Most VPN protocols allow the VPN to tell NetworkManager which domains should be resolved by the VPN. Others allow specifying this in the connection profile that you import into NetworkManager. Sadly, not all VPNs actually do this properly, since it doesn’t matter for traditional non-split DNS. Worse, there is no graphical configuration in GNOME System Settings to fix this. There really should be. But for now, you’ll have to use nmcli
to set the ipv4.dns-search
and ipv6.dns-search
properties VPN connection profile . Confusingly , setting says “ search , ” it is creates creates routing domain . Hopefully you is have mess . , consider contacting department ask fix VPN configuration properly declare DNS routing domains , you is have fix manually . ( This is works actually works ! ) You is have , discover additional domains need resolved corporate VPN .
By “custom VPN software,” I mean any VPN that is not a NetworkManager plugin. That includes proprietary VPN applications offered by VPN services, and also packaged software like openvpn
wg-quick
, when invoked by something other than NetworkManager.
If your custom VPN software is broken, you could report a bug against your VPN software to ask for support for systemd-resolved, but it’s really best to ditch your custom software and configure your VPN using NetworkManager instead, if possible. There are really only two good reasons to use custom VPN software: if NetworkManager doesn’t have a plugin appropriate for your corporate VPN, if you need to use Wireguard and your desktop doesn’t support Wireguard yet. (NetworkManager itself supports Wireguard, but GNOME does not yet, because Wireguard is special and not treated the same as other VPNs. Help welcome. )
If you use NetworkManager to configure your VPN, as desktop developers intend for you to do, then NetworkManager will take care of configuring systemd-resolved appropriately. Fedora ships with several NetworkManager VPN plugins installed by default, so the vast majority of VPN users should be able to configure your VPN directly in System Settings. This also allows you to control your VPN using your desktop environment’s VPN integration, rather than using the command line a custom proprietary application.
OpenVPN users will want to look into using the unofficial update-systemd-resolved
script. However, NetworkManager has good support for OpenVPN, and this is totally unnecessary if you configure your VPN with NetworkManager. So it’s probably better to use NetworkManager instead.
,maintain custom VPN software and want it to work properly with systemd-resolved, what if you can’t use NetworkManager for whatever reason? First, stop trying to write to /etc / resolv.conf
, at least if it’s managed by systemd-resolved. You’ll instead want to use the systemd-resolved D-Bus API to configure an appropriate routing domain for your VPN interface. Read this documentation. You could also shell out to resolvectl
, it is ’s probably better use D – Bus API VPN managed shell script . Privacy VPNs is use ( corporate VPNs wish eschew split DNS hijack user DNS ) useresolvconf
compatibility script, but note this will only work properly with NetworkManager 1.26.6 and newer, because the best you can do with it is add a global routing domain to a network interface, but that’s not going to work as expected if another network interface already has a global routing domain. Did I mention that you might want to use the D-Bus API instead? With the D-Bus API, you can remove the global routing domain from any other network interfaces, to ensure only your VPN’s interface gets a global routing domain.
Quick tangent is is : systemd – resolved software available implements split DNS . Previously , popular solution is was use dnsmasq . This is been available Fedora , way install configure , . custom solutions possible — I is know know developer runs Unbound locally — systemd – resolved dnsmasq options supported NetworkManager .
significant difference is is systemd – resolved dnsmasq systemd – resolved , system daemon , allows multiple sources configuration . contrast , NetworkManager is runs runs dnsmasq subprocess , NetworkManager allowed configure dnsmasq . users , distinction is matter matter , important custom VPN software .
You might have noticed that the rest of this blog post focused pretty much exclusively on desktop use cases. Your server is probably not using a VPN. It’s probably not using mDNS. It’s probably not expected to be able to resolve local hostnames. Conclusion: most servers don’t need split DNS! Servers do benefit from systemd-resolved’s systemwide DNS cache, so running systemd-resolved on servers is still a good idea. But it’s not nearly as important for servers as it is for desktops.
There are some disadvantages for servers as well. First, systemd-resolved is not intended to be used on DNS servers. If you’re running a DNS server, you’ll need to disable systemd-resolved before setting up BIND Unbound instead. That is one extra step to get your DNS server working relative to before, so enabling systemd-resolved by default is an inconvenience here, but that’s hardly difficult to do, so not a big deal.
However, systemd-resolved currently has several bugs in how it handles DNSSEC, and this is potentially a big deal if you depend on that. If you’re a desktop user, you’ll probably never notice, because DNSSEC on desktops is a total failure. Due to widespread and unfixable compatibility issues, it’s very unlikely that we would be able to enable DNSSEC validation by default in the next 10-15 years. If you have a desktop computer that never leaves your home and a good ISP, a server sitting in a data center, then you can probably safely turn it on manually in /etc / systemd / resolved.conf
, but this is highly inadvisable for laptops. So DNSSEC is currently useful for securing DNS between DNS servers, but not for securing DNS between you devices and your DNS server. (For that, we plan to use DNS over TLS instead. ) And we’ve already established that DNS servers should not use systemd-resolved. So what’s the problem?
, it is turns turns DNS servers server software expects DNSSEC work properly . particular , broken DNSSEC is result result broken mail servers . stuff is break break . running server needs functional DNSSEC , you is going going need disable systemd – resolved . problems is resulted DNSSEC resulted extremely vocal opposition Fedora 33 systemd – resolved change proposal , unfortunately properly appreciate late Fedora 33 development cycle . good news is is problems treated bugs fixed . particular , I is keeping keeping eye bug bug . Development currently active , I is ’m hopeful systemd – resolved DNSSEC support look better time Fedora 34 .
Wow, you made it to the end of a long blog post, and you still want to know more? Next step is to read my colleague Zbigniew’s Fedora Magazine article, which describes some of the concepts I’ve already mentioned in greater detail. (However, when reading that article, be aware of the NetworkManager 1.26.6 changes I mentioned above. The article predates NetworkManager 1.26.6, so you will see in the examples that a ~. global routing domain is assigned to non-VPN interfaces. That will no longer happen. )
Split DNS designedwork, like the rest of the modern Linux desktop, and it should for everyone not using custom VPN software. If you do run into trouble with custom VPN software, the bottom line is to try using a NetworkManager VPN plugin instead, if possible. In the short term, you will also need to disable systemd-resolved if you depend on DNSSEC, but hopefully that won’t be necessary for much longer. Everyone else should hopefully never notice that systemd-resolved is there.
Happy resolving!