(A follow up to similar question for 12.04.)
Prior to Ubuntu 12.04, you may see the active DNS in /etc/resolv.conf
. In Ubuntu 12.04, NetworkManager no longer works with the file. You have to directly consult the command line tool nm-tool
.
Interestingly, nm-tool
is no longer installed by default in 14.04 and later. Although you may still install through apt-get install
, you can't assume all Ubuntu to have that out of the box.
So the question remains. How do you know, by default installation, the DNS you're using by command line?
Best Answer
Quick Answer
A new NetworkManager tool
nmcli
is installed by default now. The command line tool is very powerful but a bit harder to learn. Stick to our question, the short answer is:or, to have cleaner output
Explain
If you have time, I can explain the above jumbo-mumble:
nmcli dev show
Works a bit like the old
nm-tool
command. It elaborate the current networking info.You may also learn the setting of a certain interface by adding the interface name. For example, to learn the information of
eth0
, you may usenmcli dev show eth0
.grep DNS
Obviously grep only the lines with the text "DNS" in it.
sed 's/\s\s*/\t/g' | cut -f 2
This is only to clean up the output. The
cut
may select the output by column, but it takes only 1 character as separator (whilenmcli
uses MANY SPACE). Thesed
turns the spaces, in original output, into TAB.