Check DNS (Domain Name Server) Records On Linux Using Nslookup Command

Nslookup is a program to query Internet domain name servers. Nslookup has two modes interactive and non-interactive.

Interactive mode allows the user to query name servers for information about various hosts and domains or to print a list of hosts in a domain.

Non-interactive mode is used to print just the name and requested information for a host or domain.

It’s network administration tool which will help them to check and troubleshoot DNS related issues. Alternatively we can Lookup the DNS records using dig command & host command.

1) How to Lookup domain IP address / A record ?

Use the nslookup command followed by corresponding Domain Name to lookup the domain A record / IP address.

# Common Syntax for nslookup command #
# nslookup [-Options] [domainname.com]

# Lookup 2daygeek.com domain A Record / IP Address #
# nslookup 2daygeek.com
Server:         83.170.64.2
Address:        83.170.64.2#53

Non-authoritative answer:
Name:   2daygeek.com
Address: 182.71.233.70

The output is clearly shows, server is referred the DNS server IP address and 53 is referred DNS service port number.

2) How to Lookup the domain MX record ?

Use the nslookup command followed by corresponding domain name with query=MX to lookup the domain MX records.

# nslookup -query=mx 2daygeek.com
;; Got SERVFAIL reply from 83.170.69.2, trying next server
Server:         83.170.64.2
Address:        83.170.64.2#53

Non-authoritative answer:
2daygeek.com    mail exchanger = 0 2daygeek.com.

Authoritative answers can be found from:
2daygeek.com    nameserver = ns1.2daygeek.in.
2daygeek.com    nameserver = ns2.2daygeek.in.
2daygeek.com    internet address = 182.71.233.70
ns1.2daygeek.in        internet address = 182.71.233.70
ns2.2daygeek.in        internet address = 182.71.233.70

The above output clearly shows, we have found only one mx record and the priority is 0.

3) How to Lookup the domain NS record ?

Use the nslookup command followed by corresponding domain name with type=ns to lookup the domain Name Servers records.

# nslookup -type=ns 2daygeek.com
Server:         83.170.69.2
Address:        83.170.69.2#53

Non-authoritative answer:
2daygeek.com    nameserver = ns1.2daygeek.in.
2daygeek.com    nameserver = ns2.2daygeek.in.

Authoritative answers can be found from:

4) How to Lookup the domain TXT (SPF) record ?

Use the nslookup command followed by corresponding domain name with type=txt to lookup the domain TXT or SPF records.

# nslookup -type=txt 2daygeek.com
Server:         83.170.64.2
Address:        83.170.64.2#53

Non-authoritative answer:
2daygeek.com    text = "v=spf1 ip4:182.71.233.70 +a +mx +ip4:49.50.66.31 ?all"

Authoritative answers can be found from:
2daygeek.com    nameserver = ns2.2daygeek.in.
2daygeek.com    nameserver = ns1.2daygeek.in.
ns1.2daygeek.in        internet address = 182.71.233.70
ns2.2daygeek.in        internet address = 182.71.233.70

5) How to Lookup the domain Cname record ?

Use the nslookup command followed by corresponding domain name with type=cname to lookup the domain cname record.

# nslookup -type=cname 2daygeek.com
;; Got SERVFAIL reply from 83.170.69.2, trying next server
Server:         83.170.64.2
Address:        83.170.64.2#53

Non-authoritative answer:
*** Can't find 2daygeek.com: No answer

Authoritative answers can be found from:
2daygeek.com
        origin = ns1.2daygeek.in
        mail addr = magesh.gmail.com
        serial = 2013110202
        refresh = 86400
        retry = 7200
        expire = 3600000
        minimum = 86400

6) How to Lookup the domain SOA record ?

Use the nslookup command followed by corresponding domain name with type=soa to lookup the domain SOA record.

# nslookup -type=soa 2daygeek.com
Server:         83.170.69.2
Address:        83.170.69.2#53

Non-authoritative answer:
2daygeek.com
        origin = ns1.2daygeek.in
        mail addr = magesh.gmail.com
        serial = 2013110202
        refresh = 86400
        retry = 7200
        expire = 3600000
        minimum = 86400

Authoritative answers can be found from:
2daygeek.com    nameserver = ns2.2daygeek.in.
2daygeek.com    nameserver = ns1.2daygeek.in.

7) How to Lookup the domain reverse DNS (PTR) record ?

Use the nslookup command followed by corresponding domain IP address to lookup the domain PTR record.

# nslookup 182.71.233.70
Server:         83.170.69.2
Address:        83.170.69.2#53

Non-authoritative answer:
70.233.71.182.in-addr.arpa      name = NSG-Static-070.233.71.182.airtel.in.

Authoritative answers can be found from:
71.182.in-addr.arpa     nameserver = aaadel.mantraonline.com.
71.182.in-addr.arpa     nameserver = dnsdel.mantraonline.com.
aaadel.mantraonline.com internet address = 202.56.230.6
aaadel.mantraonline.com has AAAA address 2404:a800:0:b::9
dnsdel.mantraonline.com internet address = 202.56.230.5
dnsdel.mantraonline.com has AAAA address 2404:a800:0:b::7

8) How to Lookup ALL domain records ?

Use the nslookup command followed by corresponding domain name with type=any to lookup the entire domain records.

# nslookup -type=any 2daygeek.com
Server:         83.170.69.2
Address:        83.170.69.2#53

Non-authoritative answer:
2daygeek.com
        origin = ns1.2daygeek.in
        mail addr = magesh.gmail.com
        serial = 2013110202
        refresh = 86400
        retry = 7200
        expire = 3600000
        minimum = 86400
2daygeek.com    nameserver = ns1.2daygeek.in.
2daygeek.com    nameserver = ns2.2daygeek.in.

Authoritative answers can be found from:
2daygeek.com    nameserver = ns2.2daygeek.in.
2daygeek.com    nameserver = ns1.2daygeek.in.

9) How to Lookup particular nameserver IP address / record ?

Use the nslookup command followed by corresponding domain name & corresponding domain name server either ns1.2daygeek.in or ns2.2daygeek.in to lookup the particular nameserver IP address.

# nslookup 2daygeek.com ns1.2daygeek.in
Server:         ns1.2daygeek.in
Address:        182.71.233.70#53

Name:   2daygeek.com
Address: 182.71.233.70

In this article most of the examples shows “Non-authoritative answer” its mean the requested DNS server haven’t whole information of requested domain zone file. But the above request, all the zone file information is there that’s why we haven’t get any “Non-authoritative answer”.

10) How to Lookup detailed information using DEBUG mode ?

Use the nslookup command followed by -debug with corresponding domain name to lookup detailed information of DNS records.

# nslookup -debug 2daygeek.com
;; Got SERVFAIL reply from 83.170.69.2, trying next server
Server:         83.170.64.2
Address:        83.170.64.2#53

------------
    QUESTIONS:
        2daygeek.com, type = A, class = IN
    ANSWERS:
    ->  2daygeek.com
        internet address = 182.71.233.70
        ttl = 14103
    AUTHORITY RECORDS:
    ->  2daygeek.com
        nameserver = ns2.2daygeek.in.
        ttl = 86103
    ->  2daygeek.com
        nameserver = ns1.2daygeek.in.
        ttl = 86103
    ADDITIONAL RECORDS:
    ->  ns1.2daygeek.in
        internet address = 182.71.233.70
        ttl = 14103
    ->  ns2.2daygeek.in
        internet address = 182.71.233.70
        ttl = 14103
------------
Non-authoritative answer:
Name:   2daygeek.com
Address: 182.71.233.70

When i use debug option with nslookup command, we can get detailed information with ttl value (packet trasfer information).

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...