16

Is there a simple command to find out which DNS server I'm using right now? Preferably without resorting to tcpdump or parsing log files?

I found a lot of stuff about nm-cli and other nm-tools but that doesn't apply to a server...

2
  • 2
    Try just cat /etc/resolv.conf
    – kubahaha
    Jun 1, 2016 at 20:43
  • Since this has become a popular question, the answer is "resolvectl status" if you are running a server without GUI / NM / etc. And it's the 10th answer on the thread posted above. Why block this thread then, if it could provide better answers?
    – OttoEisen
    Jul 23, 2022 at 23:52

2 Answers 2

26

nslookup can be used to get the DNS server that is being used.

Example:

$ nslookup www.google.com
Server:     10.0.0.1     <--This is the DNS server address.
Address:    10.0.0.1#53

Non-authoritative answer:
Name:   www.google.com
Address: 216.58.217.36

Hope this helps!

3

For the majority of applications,

less /etc/resolv.conf

should work. Otherwise, you can try,

dig xxxxxxxxx

replacing xxxxxxxx with any server of your choice. You should see what nameserver was used to look it up.

N.B.: Don't be surprised if it is 127.0.0.1 : this is your localhost, which probably means it's your router that is determining your nameserver.

Not the answer you're looking for? Browse other questions tagged .