In this post i am going to teach How to use DIG and DIG by 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 Groper2. DIG can work on command line or as well in batch mode
3. DIG supports 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
#dig hostname
Example :
[root@ts6741 ~]# dig www.google.com
; <<>> DiG 9.3.3rc2 <<>> www.google.com
; (1 server found)
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 52434
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 3
;; QUESTION SECTION:
;www.google.com. IN A
;; ANSWER SECTION:
http://www.google.com/. 43200 IN A 200.99.187.2
;; AUTHORITY SECTION:
http://www.google.com/. 43200 IN NS ns2.google.com.
http://www.google.com/. 43200 IN NS ns3.google.com.
http://www.google.com/. 43200 IN NS ns1.google.com.
;; ADDITIONAL SECTION:
ns1.google.com. 43200 IN A 222.54.11.86
ns2.google.com. 43200 IN A 220.225.37.222
ns3.google.com. 43200 IN A 203.199.147.233
;; Query time: 1 msec
;; SERVER: 222.54.11.86#53(222.54.11.86)
;; WHEN: Wed Nov 18 18:31:12 2009
;; MSG SIZE rcvd: 152
[root@ts6741 ~]#
Here important points to know
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
#dig –x ipadd
Example :
#dig –x 192.56.78.1
#dig –x 192.56.78.1
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 :
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 http://www.google.com/ from a outside world DNS server ie 223.125.43.67
Usage4 : To dig a DNS server on a perticular port,where DNS server is running .
#dig @223.125.43.67 -p 2345 www.google.com
Note:here 223.125.43.67 is the DNS server and port 2345 where that DNS service is running.
#dig @223.125.43.67 -p 2345 www.google.com
Note:here 223.125.43.67 is the DNS server and port 2345 where that DNS service is running.
Usage6 : To get mail server details
#dig mx www.google.com
Note : This will provied all the mail servers in google.com
Note : This will provide all the Name Server records.
Please comment your thoughts regarding this post:-)