Systemd-resolved

From LinuxReviews
Jump to navigationJump to search

systemd-resolved (short: "sDrD") is a all-in-one name resolution manager which is somewhat tied to NetworkManager. Specifics of this tie-in are horrifically complex and cause endless trouble.

It can act as a service for applications and resolve regular DNS, multi-cast DNS.

Configuration

systemd-resolved is configured in the file /etc/systemd/resolved.conf where the basic options are DNS=, FallbackDNS=, MulticastDNS= and DNSStubListener=

A basic example would be:

File: /etc/systemd/resolved.conf
[Resolve]
# Resolve using Cloudflare DNS
DNS=1.1.1.1 1.0.0.1
# Fallback to Google if Cloudflare is unavailable
FallbackDNS=8.8.8.8
# Listen for multicast DNS
MulticastDNS=yes
# respond to DNS requests on 127.0.0.53
DNSStubListener=yes

The systemd-resolved manual has more details if the above isn't obvious enough for you and you want to wade through tons of nonsensical gibberish not addressing administrators interests.

Do note that there isn't much it can do in terms of multicast beyond resolving .local hostnames. You need to disable systemd-resolved's multicast DNS feature and use avahi-daemon for advanced uses like announcing services.

Turning sDrD off permanently

If you have setup your own DNS server using Unbound or something else and you do NOT want to use systemd-resolved then this is desired and required:

File: /etc/systemd/resolved.conf
[Resolve]
DNS=127.0.0.1
FallbackDNS=1.0.0.1
MulticastDNS=no
DNSStubListener=no

You need to make sure systemd-resolved is not set to listen on 127.0.0.1 with DNSStubListener=no or mDNS with MulticastDNS=no even if you have disabled it with:

systemctl disable systemd-resolved.service

It will start when certain applications make API requests to systemd when it is disabled and even when you have masked it with

systemctl mask systemd-resolved.service

systemd-resolved will also need to be disabled in NetworkManagers configuration file.

File: /etc/NetworkManager/NetworkManager.conf
[main]
dns=none
systemd-resolved=false

Disabling sDrD in the configuration files in this fashion is the recommended way, short of removing the binary – which works too – if you want sDrD disabled.