Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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:192.168.1.111  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::92e6:baff:fe22:6af2/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          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:127.0.0.1  Mask:255.0.0.0
          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:192.168.1.111 Bcast:192.168.1.255 Mask:255.255.255.0 inet addr:127.0.0.1 Mask:255.0.0.0 –  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/dhclient-529bed02-363e-4e97-bd5d-9f63f42f17f2-eth0.lease |grep dhcp-server-identifier option dhcp-server-identifier 192.168.1.1; option dhcp-server-identifier 192.168.1.1; option dhcp-server-identifier 192.168.1.1; option dhcp-server-identifier 192.168.1.1; option dhcp-server-identifier 192.168.1.1; –  Victor S Sep 22 '12 at 4:01
    
@devav2 192.168.1.1 is my router address. –  Victor S Sep 22 '12 at 4:02

4 Answers 4

up vote 8 down vote accepted

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

share|improve this answer
1  
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
$ nm-tool 

will also list DNS Servers.

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
2  
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

Your Answer

 
discard

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.