No problem to start using systemd-resolved for DNS; it is already installed by default since systemd provides it. It’s a small matter setting up a config file and enabling the service.
Read through the man page for resolved.conf to decide what options you want to set, then edit /etc/systemd/resolved.conf
(or set up some drop-in configs in /etc/systemd/resolved.conf.d/
…or both!).
Enable the service:
sudo systemctl enable --now systemd-resolved.service
Unless you want to use something other than the stub mode, set up a symlink to /etc/resolv.conf
, which is the file that a lot of software that calls for DNS resolution (web browsers, for example) will use. See this note from the ArchWiki article:
DNS
Software that relies on glibc’s getaddrinfo(3) (or similar) will work out of the box, since, by default,
/etc/nsswitch.conf
is configured to use nss-resolve(8) if it is available.To provide domain name resolution for software that reads
/etc/resolv.conf
directly, such as web browsers and GnuPG, systemd-resolved has four different modes for handling the file—stub, static, uplink and foreign. They are described in systemd-resolved(8) § /ETC/RESOLV.CONF. We will focus here only on the recommended mode, i.e. the stub mode which uses/run/systemd/resolve/stub-resolv.conf
.
/run/systemd/resolve/stub-resolv.conf
contains the local stub127.0.0.53
as the only DNS server and a list of search domains. This is the recommended mode of operation that propagates the systemd-resolved managed configuration to all clients. To use it, replace/etc/resolv.conf
with a symbolic link to it:# ln -rsf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
Note:
- Failure to properly configure
/etc/resolv.conf
will result in broken DNS resolution.- Creating the
/etc/resolv.conf
symlink will not be possible while inside arch-chroot, since the file is bind-mounted from the outside system. Instead, create the symlink from outside the chroot. E.g.# ln -sf /run/systemd/resolve/stub-resolv.conf */mnt*/etc/resolv.conf
A symlink to /etc/resolv.conf
is the only configuration I have seen used on systems that use systemd-resolved. My understanding is it’s a method that simplifies the configuration in a significant way.
That’s pretty much it to get up and going. Read through the rest of the ArchWiki article if you want to dive a little deeper on setting up DNS servers (sounds like you might want to ), or if you need to disable mDNS (it is enabled by default on systemd-resolved) or anything else like that.
I hope that helps, welcome to the community @carroarmato0.