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