In some situations could be needed to know exactly which DNS server is being used by an Ubuntu host. There are several ways to get this info, however the best option I have found is to use the resolvectl service. This service is in charge of the name resolution of the local applications.

You can use it executing resolvectl status or just resolvectl. The command will return the DNS servers configured in each network interface, and which one is currently being used.

This is an example:

yvoictra|saturn:~$ resolvectl status
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: 192.168.1.211
       DNS Servers: 192.168.1.211 8.8.8.8

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

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

And that’s all. It’s quite simple in Ubuntu to get this useful information.