How to view the DNS address assigned by DHCP?












28















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
















28















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














28












28








28


10






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
















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)






dns dhcp






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 22 '12 at 4:04







Victor S

















asked Sep 22 '12 at 3:22









Victor SVictor S

3505818




3505818













  • 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



















  • 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

















What is returned by: ifconfig | grep 'inet addr:' ?

– david6
Sep 22 '12 at 3:28







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





@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





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





@devav2 192.168.1.1 is my router address.

– Victor S
Sep 22 '12 at 4:02










10 Answers
10






active

oldest

votes


















39














Run nmcli dev list iface eth0 | grep IP4 in a terminal.
eth0 is the most common iface, but it could be eth1, eth2, etc.



This is still the command to use in Ubuntu 14.04 (LTS).



For at least Ubuntu 15.10 onwards (possibly also earlier versions), the command is nmcli device show eth0 [or your iface ]| grep IP4.






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






  • 7





    As of 15.04, the command is nmcli dev show

    – Sergiy Kolodyazhnyy
    Jun 18 '15 at 22:06






  • 3





    With nmcli dev show eth0 (as on 15.04) it also works on Debian Buster. Thanks!

    – Luc
    Jul 31 '17 at 22:47






  • 1





    @YandryPozo Posted an answer, as requested :)

    – Sergiy Kolodyazhnyy
    Sep 17 '17 at 21:19



















13














$ nm-tool 


will also list DNS Servers.






share|improve this answer



















  • 1





    +1 because this has been tested working up to 14.04 release. For 15.04 and newer release, use nmcli as suggested by the other answer instead.

    – clearkimura
    Dec 4 '15 at 4:12





















6














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



















  • 2





    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 '15 at 20:15



















4














here it is:



cat /etc/resolv.conf


but do not edit this file






share|improve this answer


























  • In recent Ubuntu releases (post 2012 I think) it won't be useful, since it will contain nameserver 127.0.1.1, referring to localhost dnsmasq installation. It's better to query NetworkManager as written by @anwar-shah and @marty-fried

    – gerlos
    Jan 14 '16 at 10:44













  • As you mention, that file can be edited and thus are not necessarily the addresses assigned by DHCP. Now if you edit it yourself then, obviously, it's going to be different -- but what if you use a company VPN? Or something else influences the file? That's why I think it's not a good answer, even if simple and universal. It's a good first place to look, but not a true answer by itself.

    – Luc
    Jul 31 '17 at 22:48





















3














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





















  • 3





    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
    Sep 22 '12 at 4:46






  • 1





    Thanks for your answer, it is convenient for gnome or KDE users.

    – Victor S
    Sep 22 '12 at 4:51



















2














My actual solution(est 2015, Ubuntu 14.04), is this:




  1. start the cli

  2. type: 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. type dig google.com

  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

































    1














    In Ubuntu 16.04, the info from dhcp is written in: /var/lib/NetworkManager/dhclient-<interface>.conf






    share|improve this answer































      1














      As I mentioned in the comments (which by popular request has become an answer now), one can use nmcli dev show as of Ubuntu 15.04. Add grep to the mix and you're set:



      $ nmcli dev show | grep 'DNS'                                                                                                                                                                     
      IP4.DNS[1]: 208.67.222.222
      IP4.DNS[2]: 208.67.220.220





      share|improve this answer































        0














        If your computer run behind of Router/WiFi of your Internet Provider, you'll get a Private IP Address from DHCP of Router, something like 192.168.0.2 or 192.168.1.100.



        To get the Public IP Address of DHCP of DNS from your Internet Provider, you need run the follow command line on terminal:



        dig +short myip.opendns.com @resolver1.opendns.com





        share|improve this answer































          0














          When your system is running systemd-resolve you can do



          systemd-resolve --status





          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "89"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f191563%2fhow-to-view-the-dns-address-assigned-by-dhcp%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            10 Answers
            10






            active

            oldest

            votes








            10 Answers
            10






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            39














            Run nmcli dev list iface eth0 | grep IP4 in a terminal.
            eth0 is the most common iface, but it could be eth1, eth2, etc.



            This is still the command to use in Ubuntu 14.04 (LTS).



            For at least Ubuntu 15.10 onwards (possibly also earlier versions), the command is nmcli device show eth0 [or your iface ]| grep IP4.






            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






            • 7





              As of 15.04, the command is nmcli dev show

              – Sergiy Kolodyazhnyy
              Jun 18 '15 at 22:06






            • 3





              With nmcli dev show eth0 (as on 15.04) it also works on Debian Buster. Thanks!

              – Luc
              Jul 31 '17 at 22:47






            • 1





              @YandryPozo Posted an answer, as requested :)

              – Sergiy Kolodyazhnyy
              Sep 17 '17 at 21:19
















            39














            Run nmcli dev list iface eth0 | grep IP4 in a terminal.
            eth0 is the most common iface, but it could be eth1, eth2, etc.



            This is still the command to use in Ubuntu 14.04 (LTS).



            For at least Ubuntu 15.10 onwards (possibly also earlier versions), the command is nmcli device show eth0 [or your iface ]| grep IP4.






            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






            • 7





              As of 15.04, the command is nmcli dev show

              – Sergiy Kolodyazhnyy
              Jun 18 '15 at 22:06






            • 3





              With nmcli dev show eth0 (as on 15.04) it also works on Debian Buster. Thanks!

              – Luc
              Jul 31 '17 at 22:47






            • 1





              @YandryPozo Posted an answer, as requested :)

              – Sergiy Kolodyazhnyy
              Sep 17 '17 at 21:19














            39












            39








            39







            Run nmcli dev list iface eth0 | grep IP4 in a terminal.
            eth0 is the most common iface, but it could be eth1, eth2, etc.



            This is still the command to use in Ubuntu 14.04 (LTS).



            For at least Ubuntu 15.10 onwards (possibly also earlier versions), the command is nmcli device show eth0 [or your iface ]| grep IP4.






            share|improve this answer















            Run nmcli dev list iface eth0 | grep IP4 in a terminal.
            eth0 is the most common iface, but it could be eth1, eth2, etc.



            This is still the command to use in Ubuntu 14.04 (LTS).



            For at least Ubuntu 15.10 onwards (possibly also earlier versions), the command is nmcli device show eth0 [or your iface ]| grep IP4.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Dec 4 '15 at 2:52

























            answered Sep 22 '12 at 4:26









            Marty FriedMarty Fried

            13.5k53947




            13.5k53947








            • 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






            • 7





              As of 15.04, the command is nmcli dev show

              – Sergiy Kolodyazhnyy
              Jun 18 '15 at 22:06






            • 3





              With nmcli dev show eth0 (as on 15.04) it also works on Debian Buster. Thanks!

              – Luc
              Jul 31 '17 at 22:47






            • 1





              @YandryPozo Posted an answer, as requested :)

              – Sergiy Kolodyazhnyy
              Sep 17 '17 at 21:19














            • 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






            • 7





              As of 15.04, the command is nmcli dev show

              – Sergiy Kolodyazhnyy
              Jun 18 '15 at 22:06






            • 3





              With nmcli dev show eth0 (as on 15.04) it also works on Debian Buster. Thanks!

              – Luc
              Jul 31 '17 at 22:47






            • 1





              @YandryPozo Posted an answer, as requested :)

              – Sergiy Kolodyazhnyy
              Sep 17 '17 at 21:19








            1




            1





            Awesome answer! Appreciate your sharing! I got it.

            – Victor S
            Sep 22 '12 at 4:42





            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





            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




            7




            7





            As of 15.04, the command is nmcli dev show

            – Sergiy Kolodyazhnyy
            Jun 18 '15 at 22:06





            As of 15.04, the command is nmcli dev show

            – Sergiy Kolodyazhnyy
            Jun 18 '15 at 22:06




            3




            3





            With nmcli dev show eth0 (as on 15.04) it also works on Debian Buster. Thanks!

            – Luc
            Jul 31 '17 at 22:47





            With nmcli dev show eth0 (as on 15.04) it also works on Debian Buster. Thanks!

            – Luc
            Jul 31 '17 at 22:47




            1




            1





            @YandryPozo Posted an answer, as requested :)

            – Sergiy Kolodyazhnyy
            Sep 17 '17 at 21:19





            @YandryPozo Posted an answer, as requested :)

            – Sergiy Kolodyazhnyy
            Sep 17 '17 at 21:19













            13














            $ nm-tool 


            will also list DNS Servers.






            share|improve this answer



















            • 1





              +1 because this has been tested working up to 14.04 release. For 15.04 and newer release, use nmcli as suggested by the other answer instead.

              – clearkimura
              Dec 4 '15 at 4:12


















            13














            $ nm-tool 


            will also list DNS Servers.






            share|improve this answer



















            • 1





              +1 because this has been tested working up to 14.04 release. For 15.04 and newer release, use nmcli as suggested by the other answer instead.

              – clearkimura
              Dec 4 '15 at 4:12
















            13












            13








            13







            $ nm-tool 


            will also list DNS Servers.






            share|improve this answer













            $ nm-tool 


            will also list DNS Servers.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Sep 22 '12 at 16:11









            dixoncxdixoncx

            36018




            36018








            • 1





              +1 because this has been tested working up to 14.04 release. For 15.04 and newer release, use nmcli as suggested by the other answer instead.

              – clearkimura
              Dec 4 '15 at 4:12
















            • 1





              +1 because this has been tested working up to 14.04 release. For 15.04 and newer release, use nmcli as suggested by the other answer instead.

              – clearkimura
              Dec 4 '15 at 4:12










            1




            1





            +1 because this has been tested working up to 14.04 release. For 15.04 and newer release, use nmcli as suggested by the other answer instead.

            – clearkimura
            Dec 4 '15 at 4:12







            +1 because this has been tested working up to 14.04 release. For 15.04 and newer release, use nmcli as suggested by the other answer instead.

            – clearkimura
            Dec 4 '15 at 4:12













            6














            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



















            • 2





              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 '15 at 20:15
















            6














            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



















            • 2





              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 '15 at 20:15














            6












            6








            6







            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













            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












            share|improve this answer



            share|improve this answer










            answered Sep 22 '12 at 5:28









            devav2devav2

            24.8k126979




            24.8k126979








            • 2





              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 '15 at 20:15














            • 2





              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 '15 at 20:15








            2




            2





            There is nothing in the /var/lib/dhcp/dhclient.leases, it is empty.

            – Victor S
            Sep 22 '12 at 5:36







            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





            $ 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 '15 at 20:15





            try /var/lib/dhcp/dhclient.eth0.leases

            – frag
            Jan 24 '15 at 20:15











            4














            here it is:



            cat /etc/resolv.conf


            but do not edit this file






            share|improve this answer


























            • In recent Ubuntu releases (post 2012 I think) it won't be useful, since it will contain nameserver 127.0.1.1, referring to localhost dnsmasq installation. It's better to query NetworkManager as written by @anwar-shah and @marty-fried

              – gerlos
              Jan 14 '16 at 10:44













            • As you mention, that file can be edited and thus are not necessarily the addresses assigned by DHCP. Now if you edit it yourself then, obviously, it's going to be different -- but what if you use a company VPN? Or something else influences the file? That's why I think it's not a good answer, even if simple and universal. It's a good first place to look, but not a true answer by itself.

              – Luc
              Jul 31 '17 at 22:48


















            4














            here it is:



            cat /etc/resolv.conf


            but do not edit this file






            share|improve this answer


























            • In recent Ubuntu releases (post 2012 I think) it won't be useful, since it will contain nameserver 127.0.1.1, referring to localhost dnsmasq installation. It's better to query NetworkManager as written by @anwar-shah and @marty-fried

              – gerlos
              Jan 14 '16 at 10:44













            • As you mention, that file can be edited and thus are not necessarily the addresses assigned by DHCP. Now if you edit it yourself then, obviously, it's going to be different -- but what if you use a company VPN? Or something else influences the file? That's why I think it's not a good answer, even if simple and universal. It's a good first place to look, but not a true answer by itself.

              – Luc
              Jul 31 '17 at 22:48
















            4












            4








            4







            here it is:



            cat /etc/resolv.conf


            but do not edit this file






            share|improve this answer















            here it is:



            cat /etc/resolv.conf


            but do not edit this file







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jun 19 '15 at 8:32









            muru

            1




            1










            answered Jun 18 '15 at 21:49









            Iulian PojarIulian Pojar

            492




            492













            • In recent Ubuntu releases (post 2012 I think) it won't be useful, since it will contain nameserver 127.0.1.1, referring to localhost dnsmasq installation. It's better to query NetworkManager as written by @anwar-shah and @marty-fried

              – gerlos
              Jan 14 '16 at 10:44













            • As you mention, that file can be edited and thus are not necessarily the addresses assigned by DHCP. Now if you edit it yourself then, obviously, it's going to be different -- but what if you use a company VPN? Or something else influences the file? That's why I think it's not a good answer, even if simple and universal. It's a good first place to look, but not a true answer by itself.

              – Luc
              Jul 31 '17 at 22:48





















            • In recent Ubuntu releases (post 2012 I think) it won't be useful, since it will contain nameserver 127.0.1.1, referring to localhost dnsmasq installation. It's better to query NetworkManager as written by @anwar-shah and @marty-fried

              – gerlos
              Jan 14 '16 at 10:44













            • As you mention, that file can be edited and thus are not necessarily the addresses assigned by DHCP. Now if you edit it yourself then, obviously, it's going to be different -- but what if you use a company VPN? Or something else influences the file? That's why I think it's not a good answer, even if simple and universal. It's a good first place to look, but not a true answer by itself.

              – Luc
              Jul 31 '17 at 22:48



















            In recent Ubuntu releases (post 2012 I think) it won't be useful, since it will contain nameserver 127.0.1.1, referring to localhost dnsmasq installation. It's better to query NetworkManager as written by @anwar-shah and @marty-fried

            – gerlos
            Jan 14 '16 at 10:44







            In recent Ubuntu releases (post 2012 I think) it won't be useful, since it will contain nameserver 127.0.1.1, referring to localhost dnsmasq installation. It's better to query NetworkManager as written by @anwar-shah and @marty-fried

            – gerlos
            Jan 14 '16 at 10:44















            As you mention, that file can be edited and thus are not necessarily the addresses assigned by DHCP. Now if you edit it yourself then, obviously, it's going to be different -- but what if you use a company VPN? Or something else influences the file? That's why I think it's not a good answer, even if simple and universal. It's a good first place to look, but not a true answer by itself.

            – Luc
            Jul 31 '17 at 22:48







            As you mention, that file can be edited and thus are not necessarily the addresses assigned by DHCP. Now if you edit it yourself then, obviously, it's going to be different -- but what if you use a company VPN? Or something else influences the file? That's why I think it's not a good answer, even if simple and universal. It's a good first place to look, but not a true answer by itself.

            – Luc
            Jul 31 '17 at 22:48













            3














            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





















            • 3





              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
              Sep 22 '12 at 4:46






            • 1





              Thanks for your answer, it is convenient for gnome or KDE users.

              – Victor S
              Sep 22 '12 at 4:51
















            3














            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





















            • 3





              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
              Sep 22 '12 at 4:46






            • 1





              Thanks for your answer, it is convenient for gnome or KDE users.

              – Victor S
              Sep 22 '12 at 4:51














            3












            3








            3







            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















            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














            share|improve this answer



            share|improve this answer








            edited Sep 22 '12 at 4:47

























            answered Sep 22 '12 at 4:28









            AnwarAnwar

            56.4k22146253




            56.4k22146253








            • 3





              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
              Sep 22 '12 at 4:46






            • 1





              Thanks for your answer, it is convenient for gnome or KDE users.

              – Victor S
              Sep 22 '12 at 4:51














            • 3





              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
              Sep 22 '12 at 4:46






            • 1





              Thanks for your answer, it is convenient for gnome or KDE users.

              – Victor S
              Sep 22 '12 at 4:51








            3




            3





            My Ubuntu has no any GUI desktop.

            – Victor S
            Sep 22 '12 at 4:44





            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
            Sep 22 '12 at 4:46





            @VictorS it shows the same information as the other answer. I checked it

            – Anwar
            Sep 22 '12 at 4:46




            1




            1





            Thanks for your answer, it is convenient for gnome or KDE users.

            – Victor S
            Sep 22 '12 at 4:51





            Thanks for your answer, it is convenient for gnome or KDE users.

            – Victor S
            Sep 22 '12 at 4:51











            2














            My actual solution(est 2015, Ubuntu 14.04), is this:




            1. start the cli

            2. type: 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. type dig google.com

            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






























              2














              My actual solution(est 2015, Ubuntu 14.04), is this:




              1. start the cli

              2. type: 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. type dig google.com

              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




























                2












                2








                2







                My actual solution(est 2015, Ubuntu 14.04), is this:




                1. start the cli

                2. type: 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. type dig google.com

                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















                My actual solution(est 2015, Ubuntu 14.04), is this:




                1. start the cli

                2. type: 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. type dig google.com

                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














                share|improve this answer



                share|improve this answer








                edited Jan 16 '16 at 13:50









                Anthon

                2542414




                2542414










                answered Apr 8 '15 at 7:57









                AltCtrlAltCtrl

                211




                211























                    1














                    In Ubuntu 16.04, the info from dhcp is written in: /var/lib/NetworkManager/dhclient-<interface>.conf






                    share|improve this answer




























                      1














                      In Ubuntu 16.04, the info from dhcp is written in: /var/lib/NetworkManager/dhclient-<interface>.conf






                      share|improve this answer


























                        1












                        1








                        1







                        In Ubuntu 16.04, the info from dhcp is written in: /var/lib/NetworkManager/dhclient-<interface>.conf






                        share|improve this answer













                        In Ubuntu 16.04, the info from dhcp is written in: /var/lib/NetworkManager/dhclient-<interface>.conf







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Jun 30 '17 at 14:43









                        Anton KrosnevAnton Krosnev

                        1135




                        1135























                            1














                            As I mentioned in the comments (which by popular request has become an answer now), one can use nmcli dev show as of Ubuntu 15.04. Add grep to the mix and you're set:



                            $ nmcli dev show | grep 'DNS'                                                                                                                                                                     
                            IP4.DNS[1]: 208.67.222.222
                            IP4.DNS[2]: 208.67.220.220





                            share|improve this answer




























                              1














                              As I mentioned in the comments (which by popular request has become an answer now), one can use nmcli dev show as of Ubuntu 15.04. Add grep to the mix and you're set:



                              $ nmcli dev show | grep 'DNS'                                                                                                                                                                     
                              IP4.DNS[1]: 208.67.222.222
                              IP4.DNS[2]: 208.67.220.220





                              share|improve this answer


























                                1












                                1








                                1







                                As I mentioned in the comments (which by popular request has become an answer now), one can use nmcli dev show as of Ubuntu 15.04. Add grep to the mix and you're set:



                                $ nmcli dev show | grep 'DNS'                                                                                                                                                                     
                                IP4.DNS[1]: 208.67.222.222
                                IP4.DNS[2]: 208.67.220.220





                                share|improve this answer













                                As I mentioned in the comments (which by popular request has become an answer now), one can use nmcli dev show as of Ubuntu 15.04. Add grep to the mix and you're set:



                                $ nmcli dev show | grep 'DNS'                                                                                                                                                                     
                                IP4.DNS[1]: 208.67.222.222
                                IP4.DNS[2]: 208.67.220.220






                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Sep 17 '17 at 21:19









                                Sergiy KolodyazhnyySergiy Kolodyazhnyy

                                71.8k9148314




                                71.8k9148314























                                    0














                                    If your computer run behind of Router/WiFi of your Internet Provider, you'll get a Private IP Address from DHCP of Router, something like 192.168.0.2 or 192.168.1.100.



                                    To get the Public IP Address of DHCP of DNS from your Internet Provider, you need run the follow command line on terminal:



                                    dig +short myip.opendns.com @resolver1.opendns.com





                                    share|improve this answer




























                                      0














                                      If your computer run behind of Router/WiFi of your Internet Provider, you'll get a Private IP Address from DHCP of Router, something like 192.168.0.2 or 192.168.1.100.



                                      To get the Public IP Address of DHCP of DNS from your Internet Provider, you need run the follow command line on terminal:



                                      dig +short myip.opendns.com @resolver1.opendns.com





                                      share|improve this answer


























                                        0












                                        0








                                        0







                                        If your computer run behind of Router/WiFi of your Internet Provider, you'll get a Private IP Address from DHCP of Router, something like 192.168.0.2 or 192.168.1.100.



                                        To get the Public IP Address of DHCP of DNS from your Internet Provider, you need run the follow command line on terminal:



                                        dig +short myip.opendns.com @resolver1.opendns.com





                                        share|improve this answer













                                        If your computer run behind of Router/WiFi of your Internet Provider, you'll get a Private IP Address from DHCP of Router, something like 192.168.0.2 or 192.168.1.100.



                                        To get the Public IP Address of DHCP of DNS from your Internet Provider, you need run the follow command line on terminal:



                                        dig +short myip.opendns.com @resolver1.opendns.com






                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered Dec 3 '15 at 23:16









                                        Fernando SantucciFernando Santucci

                                        8351714




                                        8351714























                                            0














                                            When your system is running systemd-resolve you can do



                                            systemd-resolve --status





                                            share|improve this answer




























                                              0














                                              When your system is running systemd-resolve you can do



                                              systemd-resolve --status





                                              share|improve this answer


























                                                0












                                                0








                                                0







                                                When your system is running systemd-resolve you can do



                                                systemd-resolve --status





                                                share|improve this answer













                                                When your system is running systemd-resolve you can do



                                                systemd-resolve --status






                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered 14 mins ago









                                                EelkeEelke

                                                1564




                                                1564






























                                                    draft saved

                                                    draft discarded




















































                                                    Thanks for contributing an answer to Ask Ubuntu!


                                                    • Please be sure to answer the question. Provide details and share your research!

                                                    But avoid



                                                    • Asking for help, clarification, or responding to other answers.

                                                    • Making statements based on opinion; back them up with references or personal experience.


                                                    To learn more, see our tips on writing great answers.




                                                    draft saved


                                                    draft discarded














                                                    StackExchange.ready(
                                                    function () {
                                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f191563%2fhow-to-view-the-dns-address-assigned-by-dhcp%23new-answer', 'question_page');
                                                    }
                                                    );

                                                    Post as a guest















                                                    Required, but never shown





















































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown

































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown







                                                    Popular posts from this blog

                                                    GameSpot

                                                    connect to host localhost port 22: Connection refused

                                                    Getting a Wifi WPA2 wifi connection