8 Linux Nslookup Commands to Troubleshoot DNS (Domain Name Server)

nslookup is a command-line administrative tool for testing and troubleshooting DNS servers (Domain Name Server). It is used to query specific DNS resource records (RR) as well. Most operating systems comes with built-in nslookup feature.

Linux Nslookup Commands

Linux Nslookup Commands

This article demonstrates widely used nslookup command in detail. Nslookup can be run in two modes: Interactive and Non-Interactive. The Interactive mode is used to query DNS-Server about various domains and hosts. Non-Interactive mode is used to query about information of a domain or host.

You might also be interested in following article :

  1. 35 Practical Examples of Linux Find Command
  2. 20 Netstat Commands for Linux Network Management
  3. 20 Linux YUM (Yellowdog Updater, Modified) Commands for Package Management

1. Find out “A” record (IP address) of Domain

# nslookup yahoo.com

Server:         4.2.2.2
Address:        4.2.2.2#53

Non-authoritative answer:
Name:   yahoo.com
Address: 72.30.38.140
Name:   yahoo.com
Address: 98.139.183.24
Name:   yahoo.com
Address: 209.191.122.70

Above command query domain www.yahoo.com with 4.2.2.2 public DNS server and below section shows Non-authoritative answer: displays A record of www.yahoo.com

2. Find out Reverse Domain Lookup

# nslookup 209.191.122.70

Server:         4.2.2.2
Address:        4.2.2.2#53

Non-authoritative answer:
70.122.191.209.in-addr.arpa     name = ir1.fp.vip.mud.yahoo.com.

Authoritative answers can be found from:

3. Find out specific Domain Lookup.

# nslookup ir1.fp.vip.mud.yahoo.com.

Server:         4.2.2.2
Address:        4.2.2.2#53

Non-authoritative answer:
Name:   ir1.fp.vip.mud.yahoo.com
Address: 209.191.122.70

4. To Query MX (Mail Exchange) record.

# nslookup -query=mx www.yahoo.com

Server:         4.2.2.2
Address:        4.2.2.2#53

Non-authoritative answer:
www.yahoo.com   canonical name = fd-fp3.wg1.b.yahoo.com.
fd-fp3.wg1.b.yahoo.com  canonical name = ds-fp3.wg1.b.yahoo.com.
ds-fp3.wg1.b.yahoo.com  canonical name = ds-any-fp3-lfb.wa1.b.yahoo.com.
ds-any-fp3-lfb.wa1.b.yahoo.com  canonical name = ds-any-fp3-real.wa1.b.yahoo.com.

Authoritative answers can be found from:
wa1.b.yahoo.com
        origin = yf1.yahoo.com
        mail addr = hostmaster.yahoo-inc.com
        serial = 1344827307
        refresh = 30
        retry = 30
        expire = 86400
        minimum = 1800

MX record is being used to map a domain name to a list of mail exchange servers for that domain. So that it tells that whatever mail received / sent to @yahoo.com will be routed to mail server.

5. To query NS(Name Server) record.

# nslookup -query=ns www.yahoo.com

Server:         4.2.2.2
Address:        4.2.2.2#53

Non-authoritative answer:
www.yahoo.com   canonical name = fd-fp3.wg1.b.yahoo.com.
fd-fp3.wg1.b.yahoo.com  canonical name = ds-fp3.wg1.b.yahoo.com.
ds-fp3.wg1.b.yahoo.com  canonical name = ds-any-fp3-lfb.wa1.b.yahoo.com.
ds-any-fp3-lfb.wa1.b.yahoo.com  canonical name = ds-any-fp3-real.wa1.b.yahoo.com.

Authoritative answers can be found from:
wa1.b.yahoo.com
        origin = yf1.yahoo.com
        mail addr = hostmaster.yahoo-inc.com
        serial = 1344827782
        refresh = 30
        retry = 30
        expire = 86400
        minimum = 1800

6. To query SOA (Start of Authority) record.

# nslookup -type=soa www.yahoo.com

Server:         4.2.2.2
Address:        4.2.2.2#53

Non-authoritative answer:
www.yahoo.com   canonical name = fd-fp3.wg1.b.yahoo.com.
fd-fp3.wg1.b.yahoo.com  canonical name = ds-fp3.wg1.b.yahoo.com.
ds-fp3.wg1.b.yahoo.com  canonical name = ds-any-fp3-lfb.wa1.b.yahoo.com.
ds-any-fp3-lfb.wa1.b.yahoo.com  canonical name = ds-any-fp3-real.wa1.b.yahoo.com.

Authoritative answers can be found from:
wa1.b.yahoo.com
        origin = yf1.yahoo.com
        mail addr = hostmaster.yahoo-inc.com
        serial = 1344827965
        refresh = 30
        retry = 30
        expire = 86400
        minimum = 1800

7. To query all Available DNS records.

# nslookup -query=any yahoo.com

Server:         4.2.2.2
Address:        4.2.2.2#53

Non-authoritative answer:
yahoo.com
        origin = ns1.yahoo.com
        mail addr = hostmaster.yahoo-inc.com
        serial = 2012081016
        refresh = 3600
        retry = 300
        expire = 1814400
        minimum = 600
Name:   yahoo.com
Address: 98.139.183.24
Name:   yahoo.com
Address: 209.191.122.70
Name:   yahoo.com
Address: 72.30.38.140
yahoo.com       mail exchanger = 1 mta7.am0.yahoodns.net.
yahoo.com       mail exchanger = 1 mta5.am0.yahoodns.net.
yahoo.com       mail exchanger = 1 mta6.am0.yahoodns.net.
yahoo.com       nameserver = ns3.yahoo.com.
yahoo.com       nameserver = ns4.yahoo.com.
yahoo.com       nameserver = ns2.yahoo.com.
yahoo.com       nameserver = ns8.yahoo.com.
yahoo.com       nameserver = ns1.yahoo.com.
yahoo.com       nameserver = ns6.yahoo.com.
yahoo.com       nameserver = ns5.yahoo.com.

Authoritative answers can be found from:

8. Enable Debug mode

To enable Debug Mode ‘set debug’ will return you verbose information like TTL, here’s the output.

# nslookup -debug yahoo.com

> set debug
> yahoo.com
Server:         4.2.2.2
Address:        4.2.2.2#53

------------
    QUESTIONS:
        yahoo.com, type = A, class = IN
    ANSWERS:
    ->  yahoo.com
        internet address = 72.30.38.140
        ttl = 1523
    ->  yahoo.com
        internet address = 98.139.183.24
        ttl = 1523
    ->  yahoo.com
        internet address = 209.191.122.70
        ttl = 1523
    AUTHORITY RECORDS:
    ADDITIONAL RECORDS:
------------
Non-authoritative answer:
Name:   yahoo.com
Address: 72.30.38.140
Name:   yahoo.com
Address: 98.139.183.24
Name:   yahoo.com
Address: 209.191.122.70

In this article, we have tried to cover nslookup commands which may help you to search (DNS) Domain Name Service related information. Next article will be on Linux Dig command which is Similar to nslookup. If you liked the article please share with your friends and don’t forget to give your valuable feedback’s through comment box.

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Ravi Saive

I am Ravi Saive, creator of TecMint. A Computer Geek and Linux Guru who loves to share tricks and tips on Internet. Most Of My Servers runs on Open Source Platform called Linux. Follow Me: Twitter, Facebook and Google+

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

11 Responses

  1. Vinod B says:

    Hi,

    I have a query regarding DNS resolution in Linux. I have entered the DNS servers in the resolve.conf. But the client is complaining that there is intermittent resolution problems. But when I am checking with nslookup and dig not finding any issues. Is there any way i can check the historical DNS resolution errors as to find when these kind issues were happening.

    Regards,
    Vinod

    • Ravi Saive says:

      @Vinod,

      May be the issue with their network setup, try to use same dig and nslookup commands from other network sources and see any issues..

      • Vinod B says:

        Hi Ravi,

        Thanks for your update. Apart from this, is there any logs which I can investigate to find when the issue is happening. Since it is inttermittent issue and currentky the resolution is happening.

        Regards,
        Vinod

        • Ravi Saive says:

          @Vinod,

          Unfortunately, there isn’t any logs for dig and nslookup requests, you need to find out yourself the issue..

  2. Santosh Lohar says:

    nice Article Ravi

  3. shree says:

    The commands used to troubleshoot DNS activity are
    a) NSLOOKUP
    b) IPCONFIG /registerdns
    c) IPCONFIG /displaydns
    d) All the Option
    can i get the ans pls

  4. Antonio Guimaraes says:

    Sr Ravi
    Im new in Oracle 11g… a install Centos 6.4 linux in VM VirtualBox 4.2.12 and a could not do de YUM UPDATE… error Canot find a Valid Baseurl for repo base. And also i need know
    what have to do next for istall Oracle 11g ..please help me
    I want learn that….please.
    Thankyou for your time and atencion.
    Antony

    • Ravi Saive says:

      Is your /etc/resolv.conf file has proper dns entries? If no, add your network DNS entries to this file and try again.

  5. sushant says:

    excellent !but i am not getting reply usally if i raise any query ?? :(

  6. MAC says:

    I remember hearing nslookup was going to be depredicated is this still the case. I know dig was pushed before, can anyone give an update.

    thanks

Leave a Reply to shree Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.