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 systemd service systemd-resolve. This service is in charge of the name resolution of the local applications.
You can use it executing systemd-resolve --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:~$ systemd-resolve --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: 8.8.4.4
DNS Servers: 192.168.1.210 8.8.4.4
Link 3 (wlan0)
Current Scopes: DNS
Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 8.8.8.8
DNS Servers: 8.8.8.8 8.8.4.4
And that’s all. It’s quite simple in Ubuntu to get this useful information.