In this post I am going to teach How to use DIG and with examples.

DIG is one of the most important tool in debugging DNS server related issues.

Some points to be noted about DIG.

1.DIG full-form/abbreviation is Domain Information Groper

2.DIG can work on command line or as well in batch mode

3.DIG supports Internationalized Domain Name(IDN) convections too.

4.DIG is more advanced than older tools such as nslookup and host commands.
5.DIG output have so much information than any other tool,
such as Question/Answer/Authority sections
(which we are going to discuses in this post)

Usage1 : Using DIG in basic form. 

#dig hostname 

Example :

[root@ts6741 ~]# dig

; <> DiG 9.3.3rc2 <>
; (1 server found)
;; global options: printcmd
;; Got answer:
;; ->>HEADER<;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 3
; IN A
;; AUTHORITY SECTION: 43200 IN NS 43200 IN NS 43200 IN NS
;; ADDITIONAL SECTION: 43200 IN A 43200 IN A 43200 IN A
;; Query time: 1 msec
;; WHEN: Wed Nov 18 18:31:12 2009
;; MSG SIZE rcvd: 152
[root@ts6741 ~]#

The above out we given in color coding to explain one by one as shown below.

1.DIG version in Green (9.3).

2.Question section in blue (Here it will show what you asked DIG to show up?).

3.Answer secession in red (which will show you the answer for the query you asked).

4.Authority section in brown (Which will show you who given the answer).

5.Addition Section in light blue (It will show you if any additional info that DNS server provided).

6.Total Query time in light green (Which will show how much time it takes to provide the answer).

7.Server info in light brown (This will show what the port DNS server is working).

8.Query execute date and time in dark red.

Usage2 : Using DIG for reverse lookup entries

#dig –x ipadd 

Example : 

#dig –x

Usage3 : Digging with specified DNS server. Let me put it in this way. My dns server is not working properly and I want to test some server details, for this DIG will allow you to provide a DNS sever so that DIG will get information about the required system from that DNS server. We can provide DNS server by using @ symbol as shown below. 

#dig @ns-server hostname 

Example :

#dig @

Note : Here in this example my dig will not check /etc/resolve.conf file for default DNS server entry, it will just request details of from a outside world DNS server ie

Usage4 : To dig a DNS server on a perticular port,where DNS server is running .

#dig @ -p 2345

Note:here is the DNS server and port 2345 where that DNS service is running.

Usage5 : To check the trace of the path.

#dig +trace

Usage6 : To get mail server details 

#dig mx  

Note : This will provied all the mail servers in

Usage7: To get Name server details

#dig ns

Note : This will provide all the Name Server records.

Please comment your thoughts regarding this post:-)

The following two tabs change content below.
Mr Surendra Anne is from Vijayawada, Andhra Pradesh, India. He is a Linux/Open source supporter who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. He works as Devops Engineer with Taggle systems, an IOT automatic water metering company, Sydney . You can contact him at surendra (@) linuxnix dot com.