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: 22.214.171.124 DNS Servers: 192.168.1.210 126.96.36.199 Link 3 (wlan0) Current Scopes: DNS Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported Current DNS Server: 188.8.131.52 DNS Servers: 184.108.40.206 220.127.116.11
And that’s all. It’s quite simple in Ubuntu to get this useful information.