Most Ubuntu installations will have systemd-resolved service enabled to provide network name resolution to the local applications running on the system. Some benefits of systemd-resolved includes a caching and validation of DNS/DNSSEC stub resolver. To check if the service is enabled on your Ubuntu Linux, run the following commands:

systemctl status systemd-resolved

The output should contain active (running) if the service is enabled.

● systemd-resolved.service - Network Name Resolution
     Loaded: loaded (/lib/systemd/system/systemd-resolved.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2025-03-14 17:19:07 UTC; 2 weeks 5 days ago
       Docs: man:systemd-resolved.service(8)
             man:org.freedesktop.resolve1(5)
             https://www.freedesktop.org/wiki/Software/systemd/writing-network-configuration-managers
             https://www.freedesktop.org/wiki/Software/systemd/writing-resolver-clients
   Main PID: 595 (systemd-resolve)
     Status: "Processing requests..."
      Tasks: 1 (limit: 9478)
     Memory: 9.6M
        CPU: 27.853s
     CGroup: /system.slice/systemd-resolved.service
             └─595 /lib/systemd/systemd-resolved

Notice: journal has been rotated since unit was started, output may be incomplete.

You can also verify if systemd-resolved is managing /etc/resolv.conf. It will be a symlink if managed.

$ ls -l /etc/resolv.conf
lrwxrwxrwx 1 root root 39 Oct  2  2024 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf

To output the file contents run:

cat /etc/resolv.conf

You should see 127.0.0.53 on the nameserver address.

nameserver 127.0.0.53
options edns0 trust-ad
search local

Check DNS Servers used by systemd-resolved

Run the following command to check the DNS servers used by systemd-resolved:

resolvectl status

In the output is the DNS servers for each network interface managed by systemd-resolved.

Global
       Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: stub

Link 2 (eth0)
    Current Scopes: DNS
         Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 1.1.1.1
       DNS Servers: 1.1.1.1
        DNS Domain: local

Link 3 (docker0)
Current Scopes: none
     Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported

If you only want to see global DNS servers, then run:

$ resolvectl dns
Global:
Link 2 (eth0): 1.1.1.1
Link 3 (docker0):

Override systemd-resolved DNS servers

The configuration file used by systemd-resolved service is:

cat /etc/systemd/resolved.conf

Below is an example configuration to override the system or default upstream DNS servers used by resolved service.

[Resolve]
DNS=1.1.1.1 8.8.8.8
FallbackDNS=8.8.4.4

Other parameters such as Domains to search, DNSSEC, MulticastDNS, Cache, and DNSStub can also be configured.

The service has to be restarted after making the changes:

sudo systemctl restart systemd-resolved

Confirm the changes:

$ resolvectl dns
Global: 1.1.1.1 8.8.8.8
Link 2 (eth0): 1.1.1.1
Link 3 (docker0):

🔑 Unlock the complete Ubuntu Desktop learning journey by purchasing our best selling ebook: The Ultimate Ubuntu Desktop Handbook.

LEAVE A REPLY

Please enter your comment!
Please enter your name here