How to set Systemd DNS servers for Ubuntu

With many linux systems moving from /etc/resolv.conf to systemd I was unsure how to set my DNS servers.


Add the following to /etc/systemd/resolved.conf:


Then restart with:

sudo systemctl restart systemd-resolved

Check status

You can use systemd-resolve --status or sudo resolvectl status to see the current status and should see “DNS Servers” listed. Using systemd-resolve --status | grep 'Server' shows all DNS servers both global and local to a specific network, partly because more information is shown when piped, such as with systemd-resolve --status | cat. These might be

Man pages

Following the comments in resolv.conf suggests man systemd-resolved where the inner workings are described in more detail, but man resolved.conf is was more helpful in working out what to set:

A space-separated list of IPv4 and IPv6 addresses to use as system DNS servers.

A space-separated list of IPv4 and IPv6
addresses to use as the fallback DNS servers

A space-separated list of domains. These domains are used as search suffixes when resolving single-label host names (domain names which contain no dot), in order to qualify them into fully-qualified domain names (FQDNs).

I’m curious what Domains= does, so might investigate that later. Edit: These are search domains and are prepended if you lookup a domain/url without a dot in it. E.g. if I added, then I’d be able to enter today in my URL bar and have that take me to as a kind of online hosts file shortcut.


Using dig to check DNS records, such as with dig -t cname, can be traced by appending +trace to the command.

Caches can be flushed with sudo systemd-resolve --flush-caches or sudo service dns-clean start.

For more detailed diagnostics it is possible to set sytemd-resolved into debug mode and trace the lookups, but I didn’t end up needing to do this.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: