How to check the DNS server IP being used (Ubuntu 18.04+)

If you’re using Ubuntu 18.04+ (or distro based on Ubuntu 18.04) and you would like to know which DNS servers are responsible for your connection, you can try the next options:

Option 1

nmcli dev show | grep DNS

Response:

IP4.DNS[1]:                             192.168.15.15
IP4.DNS[2]:                             192.168.15.16
IP4.DNS[3]:                             192.168.15.17

Option 2

systemd-resolve --status

Response:

....
         DNS Servers: 192.168.15.15
                      192.168.15.16
                      192.168.15.17
          DNS Domain: ~.

It contains a list under “DNS Servers” organized by link

Option 3

cat /run/systemd/resolve/resolv.conf

The well known file /etc/resolv.conf is now just a symlink to /run/systemd/resolve/stub-resolv.conf

If you want the “old way”, you can point /etc/resolv.conf directly to /run/systemd/resolve/resolv.conf

Leave a Reply

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