Check Upstream DNS Server on Ubuntu using systemd-resolved

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):

Your IT Journey Starts Here!

Ready to level up your IT skills? Our new eLearning platform is coming soon to help you master the latest technologies.

Be the first to know when we launch! Join our waitlist now.

Join our Linux and open source community. Subscribe to our newsletter for tips, tricks, and collaboration opportunities!

Recent Post

Leave a Comment

Your email address will not be published. Required fields are marked *

Related Post

Depending on the cloud image from which the instance is provisioned, an instance on any cloud platform comes with a […]

Kitty is a cross-platform GPU-based terminal emulator. It is feature-rich, written in Python and Objective C. It can easily be […]

Alacritty is the fastest available Linux terminal emulator. It makes use of GPU (Graphical Processing Unit) for rendering ensuring optimization […]

Let's Connect

Unleash the full potential of your business with CloudSpinx. Our expert solutions specialists are standing by to answer your questions and tailor a plan that perfectly aligns with your unique needs.
You will get a response from our solutions specialist within 12 hours
We understand emergencies can be stressful. For immediate assistance, chat with us now

Contact CloudSpinx today!

Download CloudSpinx Profile

Discover the full spectrum of our expertise and services by downloading our detailed Company Profile. Simply enter your first name, last name, and email address.