Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

How to view the DNS address assigned by DHCP?

ifconfig can not show it.

$ ifconfig -a
eth0      Link encap:Ethernet  HWaddr 90:e6:ba:22:6a:f2  
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::92e6:baff:fe22:6af2/64 Scope:Link
          RX packets:224856 errors:0 dropped:0 overruns:0 frame:0
          TX packets:220040 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:166848627 (166.8 MB)  TX bytes:20256333 (20.2 MB)
          Interrupt:46 Base address:0x4000 

lo        Link encap:Local Loopback  
          inet addr:  Mask:
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:5889 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5889 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:468885 (468.8 KB)  TX bytes:468885 (468.8 KB)

wlan0     Link encap:Ethernet  HWaddr 00:26:5e:e8:4f:8e  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
share|improve this question
What is returned by: ifconfig | grep 'inet addr:' ? – david6 Sep 22 '12 at 3:28
@david6 inet addr: Bcast: Mask: inet addr: Mask: – Victor S Sep 22 '12 at 3:48
This should help you cat /var/lib/dhcp3/dhclient.leases | grep dhcp-server-identifier – devav2 Sep 22 '12 at 3:53
@devav2 $ cat /var/lib/dhcp/ |grep dhcp-server-identifier option dhcp-server-identifier; option dhcp-server-identifier; option dhcp-server-identifier; option dhcp-server-identifier; option dhcp-server-identifier; – Victor S Sep 22 '12 at 4:01
@devav2 is my router address. – Victor S Sep 22 '12 at 4:02

6 Answers 6

up vote 10 down vote accepted

Enter the command nmcli dev list iface eth0 | grep IP4 in a terminal.

share|improve this answer
Awesome answer! Appreciate your sharing! I got it. – Victor S Sep 22 '12 at 4:42
Glad it helped. I found it when I wanted a way to get that info, then parse it to display on demand, as i had 3 different possible DNS servers (ISP, Google, and OpenDNS). – Marty Fried Sep 22 '12 at 15:40
As of 15.04, the command is nmcli dev show – Serg Jun 18 at 22:06
+1 to the above comment, thanks! – Bealer Oct 1 at 14:15
$ nm-tool 

will also list DNS Servers.

share|improve this answer

Windows guy here, this is my problem with Linux: I need to know what my DNS server is, for trouble shooting. This is such a basic system administrative need, having to Google tons of solutions, and none work. I am now 30 minutes into my quest, and I still don't know what my DNS server is. Ubuntu is running, I have a working network connection too, but ifconfig, syslog, netmanager, nm-tool, the GUI are all mute. I use 14.04 which is an just an itteration, it can't be such basic functionally obviously changed so much between version numbers =cough= right?

My actual solution(est 2015, Ubuntu 14.04), is this: 1. start the cli 2. Copy + paste: sudo apt-get install gnome-system-tools 3. After install succeeded, type at the terminal: network-admin

If you somehow can't do this(because Linux) then try this, though it's not good enough for me, but it got my job done: 1. dig 2. near the end you can see something like this(est. 2015) ;; SERVER: and then an IP address(at least, on my machine) THAT is the actual DNS server resolving the domain for you. That server can change per hostname though.

share|improve this answer

As another alternative to @MartyFried's answer, try this.

  1. Click on the Network connectivity icon on the top panel.

  2. Select Connection information

  3. It should show you the DNS server address

    enter image description here

share|improve this answer
My Ubuntu has no any GUI desktop. – Victor S Sep 22 '12 at 4:44
@VictorS it shows the same information as the other answer. I checked it – Anwar Shah Sep 22 '12 at 4:46
Thanks for your answer, it is convenient for gnome or KDE users. – Victor S Sep 22 '12 at 4:51

To get the DNS address

Open terminal(Ctrl+Alt+T) and type cat /var/lib/dhcp/dhclient.leases | grep dhcp-server-identifier

share|improve this answer
There is nothing in the /var/lib/dhcp/dhclient.leases, it is empty. – Victor S Sep 22 '12 at 5:36
$ file /var/lib/dhcp/dhclient.leases /var/lib/dhcp/dhclient.leases: empty – Victor S Sep 22 '12 at 5:38
try /var/lib/dhcp/dhclient.eth0.leases – frag Jan 24 at 20:15

here it is:

cat /etc/resolv.conf

but do not edit this file

share|improve this answer

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.