Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to know which DNS servers are in effect when I run commands like nslookup, dig, host, ping, etc.

The general answer is to cat /etc/resolv.conf, or to look at NetworkManager, but that's only going to show me the list of servers that I normally use. It won't show me any DNS servers that got pushed to me when I connect to a VPN.

Is there a way to get an in-order list of DNS servers that commands like nslookup, dig, host, ping, etc will attempt to use?

share|improve this question
up vote 3 down vote accepted

If you're using NetworkManager you can use the command line tool that's part of it, nmcli to get this list:

$ nmcli dev list iface wlan0 | grep IP4
IP4-SETTINGS.PREFIX:            24 (

You have to change the bit, wlan0 to whatever is your network interface. You can make it a bit more dynamic by using the iwgetid command:

$ nmcli dev list iface $(iwgetid | awk '{print $1}') | grep IP4

You can also use nm-tool to get a full report:

$ nm-tool 
  IPv4 Settings:
    Prefix:          24 (

share|improve this answer
And what if I do not use NetworkManager? – Piotr Dobrogost Feb 12 '14 at 22:29
@PiotrDobrogost - ask your Q on the main site. This Q specifically dealt with NetworkManager. Notice it was tagged as such by the OP? – slm Feb 12 '14 at 22:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.