Skip to main content

Domain Information Groper (DIG) -- DNS Query Tool

DIG is a command-line tool for querying DNS Name Server (similar to nslookup utility available in Windows and host utility). dig utility can be used for querying DNS about the host address (both A and AAAA), name server(NS), mail exchange(MX), Pointer Record(PTR), SOA (Start Of Authority) and others.

DIG is a part of BIND software package ( BIND package is developed and managed by Internet Systems Consortium ISC).

Usage Example :-




1. Ask for a host address :-
dig nkn.in

2. Ask from a specific server :-

dig nkn.in @8.8.8.8

; <<>> DiG 9.8.5-P2 <<>> nkn.in @8.8.8.8
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 13527
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;nkn.in.                                IN      A

;; ANSWER SECTION:
nkn.in.                 14103   IN      A       164.100.56.206

;; Query time: 171 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Sat Aug 03 23:22:51 India Standard Time 2013
;; MSG SIZE  rcvd: 40

3. Ask for all the records for a particular domain :-

C:\Users\kansal>dig nkn.in any @8.8.4.4

; <<>> DiG 9.8.5-P2 <<>> nkn.in any @8.8.4.4
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 41915
;; flags: qr rd ra; QUERY: 1, ANSWER: 7, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;nkn.in.                                IN      ANY

;; ANSWER SECTION:
nkn.in.                 14390   IN      SOA     nkn.in. nsadmin\@nkn.in. 2013041
601 10800 86400 1209600 14400
nkn.in.                 14390   IN      NS      ns1.nkn.in.
nkn.in.                 14390   IN      NS      ns3.nkn.in.
nkn.in.                 14390   IN      NS      ns2.nkn.in.
nkn.in.                 14390   IN      A       164.100.56.206
nkn.in.                 14390   IN      AAAA    2001:4408:5200::a464:38ce
nkn.in.                 14390   IN      MX      0 mailgw.nic.in.

;; Query time: 159 msec
;; SERVER: 8.8.4.4#53(8.8.4.4)
;; WHEN: Sat Aug 03 23:24:59 India Standard Time 2013
;; MSG SIZE  rcvd: 197

4. Find out the domain's Mail Server :-


C:\Users\kansal>dig nkn.in MX

; <<>> DiG 9.8.5-P2 <<>> nkn.in MX
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50205
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;nkn.in.                                IN      MX

;; ANSWER SECTION:
nkn.in.                 14232   IN      MX      0 mailgw.nic.in.

;; Query time: 63 msec
;; SERVER: 103.8.44.5#53(103.8.44.5)
;; WHEN: Sat Aug 03 23:32:05 India Standard Time 2013
;; MSG SIZE  rcvd: 51


5. Ask for a reverse lookup :-

C:\Users\kansal>dig -x 164.100.2.6

; <<>> DiG 9.8.5-P2 <<>> -x 164.100.2.6
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 3471
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;6.2.100.164.in-addr.arpa.      IN      PTR

;; ANSWER SECTION:
6.2.100.164.in-addr.arpa. 82055 IN      PTR     mailgw-hyd.nic.in.

;; Query time: 70 msec
;; SERVER: 103.8.44.5#53(103.8.44.5)
;; WHEN: Sat Aug 03 23:29:52 India Standard Time 2013
;; MSG SIZE  rcvd: 73

6. Check for DNSSEC Validation :-


C:\Users\kansal>
C:\Users\kansal>dig apnic.net +dnssec @8.8.8.8

; <<>> DiG 9.8.5-P2 <<>> apnic.net +dnssec @8.8.8.8
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8543
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags: do; udp: 512
;; QUESTION SECTION:
;apnic.net.                     IN      A

;; ANSWER SECTION:
apnic.net.              3600    IN      A       202.12.29.175
apnic.net.              3600    IN      RRSIG   A 8 2 3600 20130903002809 201308
03232809 42189 apnic.net. Q9D9OKv2qfjs33C3yyuAJhkdxy0ytjgAmsXTjVveVGwXqEcL0tEz7g
2f FKM+RykyuqxG/Tq2mxSlBrxgkhvomBLyR9OpCKvYPPST6deR6DWlztOa DIMYZ90gvpqBDGSiSafr
xcvXAr0ZTUgBZcIAtkOpzEpoOa1zP1f6VRVA vMM=

;; Query time: 386 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Sun Aug 04 11:07:27 India Standard Time 2013
;; MSG SIZE  rcvd: 223
7. Trace the DNS Query :-


C:\Users\kansal>dig india.gov.in +trace

; <<>> DiG 9.8.5-P2 <<>> india.gov.in +trace
;; global options: +cmd
.                       31101   IN      NS      l.root-servers.net.
.                       31101   IN      NS      h.root-servers.net.
.                       31101   IN      NS      c.root-servers.net.
.                       31101   IN      NS      g.root-servers.net.
.                       31101   IN      NS      m.root-servers.net.
.                       31101   IN      NS      e.root-servers.net.
.                       31101   IN      NS      b.root-servers.net.
.                       31101   IN      NS      a.root-servers.net.
.                       31101   IN      NS      j.root-servers.net.
.                       31101   IN      NS      d.root-servers.net.
.                       31101   IN      NS      f.root-servers.net.
.                       31101   IN      NS      k.root-servers.net.
.                       31101   IN      NS      i.root-servers.net.
;; Received 228 bytes from 103.8.44.5#53(103.8.44.5) in 1471 ms

in.                     172800  IN      NS      a0.in.afilias-nst.info.
in.                     172800  IN      NS      a1.in.afilias-nst.in.
in.                     172800  IN      NS      a2.in.afilias-nst.info.
in.                     172800  IN      NS      b0.in.afilias-nst.org.
in.                     172800  IN      NS      b1.in.afilias-nst.in.
in.                     172800  IN      NS      b2.in.afilias-nst.org.
in.                     172800  IN      NS      c0.in.afilias-nst.info.
in.                     172800  IN      NS      ns7.cdns.net.
;; Received 495 bytes from 128.63.2.53#53(h.root-servers.net) in 2994 ms

india.gov.in.           86400   IN      NS      ns7.nic.in.
india.gov.in.           86400   IN      NS      ns1.nic.in.
india.gov.in.           86400   IN      NS      ns10.nic.in.
india.gov.in.           86400   IN      NS      ns2.nic.in.
;; Received 107 bytes from 199.7.87.1#53(a0.in.afilias-nst.info) in 757 ms

india.gov.in.           1800    IN      A       164.100.56.191
india.gov.in.           1800    IN      NS      ns2.nic.in.
india.gov.in.           1800    IN      NS      ns1.nic.in.
india.gov.in.           1800    IN      NS      ns10.nic.in.
india.gov.in.           1800    IN      NS      ns7.nic.in.
;; Received 199 bytes from 164.100.14.3#53(ns1.nic.in) in 55 ms


The above output show you how DNS queries works.
In the above query, i ask for "trace" for the india.gov.in domain.

My resolver first goes to "." (Root NameServer) as every resolver knows about Root Servers only. Root NS replies that 'he don't know about india.gov.in' but he knows about 'NS of .in domain'.
Then resolver goes to NS of ".in" domain and ask for india.gov.in, which in turn replies that he only knows about NS of india.gov.in.
Then resolver goes to NS of 'india.gov.in' which in turn replies the desired query answer.




Popular posts from this blog

Availability of 5 GHz WLAN Channels in India under unlicensed band

Availability of 5 GHz WLAN Channels in India under unlicensed band  In India, Wireless Planning and Coordination Wing of Department of Telecom, under Ministry of Communication takes care of licensing of radio frequencies.  In the latest National Frequency allocation plan 2018 (https://dot.gov.in/sites/default/files/NFAP%202018.pdf), Government of India (GoI), exempted the licensing requirements of the following radio frequency ranges for wireless usage and a gazette notification has also published for this (https://dot.gov.in/sites/default/files/License%20Exemption%20in%205%20GHz%20G_S_R_1048%28E%29%20dated%2022nd%20October%2C%202018_0.pdf)  -- 1.  5150-5250 2. 5250-5350 3. 5470-5725 4. 5725-5875 References

Why we have IPv6 after IPv4..... Where is IPv5 ?

IP or Internet Protocol, is the primary network protocol used on the Internet, introduced by Vint Cerf and Bob Kahn in 1974. IP version 0 to 3 was introduced and used between 1974 and 1979. After changes and refinements in initial IP protocol, version 4 was introduced in 1981, commonly known as IPv4, described in RFC 791 , which become the backbone of Whole Internet in no time. (IPv4 is know as v4 because it is the fourth version of IP not because it has 4 octets, which is a common myth). TCP/IP Protocol was designed as a part of project ARPANET, whose aim was to interconnect various universities and research institutes of USA. But with the dot com boom, TCP/IP grows like anything and its become a victim of its own success. In Early 90's, expert realized that we will exhaust the whole IPv4 number very soon and there is a need for a new protocol, which should be enough in size to serve the internet community for at least 30-40 years. This lead to new version of Internet Protoco...

Shouldn't India have a Root Server ???

A Root name server is a name server for DNS root zone. Every new DNS query resolved by our local resolver first goes to Root Name Server and then root name server directs it to required domain server. This means that if in any case, root name servers goes down, then whole internet goes down (don't worry this cannot be done so easily as most of root name servers are running on Anycast and located all over the world). Recently, an anonymous group posted, to target these 13 root name severs and to bring them down by DDOS attack on 31st March 2011, to protest against SOPA and PIPA. But as expected, they didn't succeed. The last time someone seriously tried to take out the root servers was about 4 or 5 years ago and they managed to take down six out of thirteen servers. I am not saying that it could not be done but it would be tough. Every root name server is operated by different organization (except 'A' and 'J' which are operated by VeriSign) but they all po...