Understanding the dig command output

Fig. 01: The default dig command output

Fig. 01: The default dig command output

The default dig command output is divided four sections as follows. First, I type the following command to find out the IP address of host called google.com:

dig  www.cyberciti.biz

OR

dig google.com

Sample outputs:

; <<>> DiG 9.8.3-P1 <<>> google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 61867
;; flags: qr rd ra; QUERY: 1, ANSWER: 11, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;google.com.			IN	A

;; ANSWER SECTION:
google.com.		203	IN	A	74.125.236.161
google.com.		203	IN	A	74.125.236.167
google.com.		203	IN	A	74.125.236.168
google.com.		203	IN	A	74.125.236.164
google.com.		203	IN	A	74.125.236.166
google.com.		203	IN	A	74.125.236.160
google.com.		203	IN	A	74.125.236.174
google.com.		203	IN	A	74.125.236.162
google.com.		203	IN	A	74.125.236.169
google.com.		203	IN	A	74.125.236.163
google.com.		203	IN	A	74.125.236.165

;; Query time: 27 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Mon Jan 13 17:03:08 2014
;; MSG SIZE  rcvd: 204

The opening section

The first line provide information about dig command version and the options that are used by dig. To hide this info pass the +nocmd option to dig command as follows:

dig +nocmd www.cyberciti.biz
dig +nocmd google.com

The question section

The question section, display your query. In this example, my question was – “What is the IP address of a google.com?” or “What is the IP address of www.cyberciti.biz?”. Again, you can hide the question section by passing the +noquestion option to dig command as follows:

dig +noquestion www.cyberciti.biz
dig +noquestion google.com

The answer section

Finally, you get the answer to your question (“What is the IP address of a google.com?”) in the answer section. You will also get some technical details about the answer from the dns server. Again, you can hide the technical info in answer section by passing the +nocomments option to dig command as follows:

dig +nocomments www.cyberciti.biz
dig +nocomments google.com

The additional section

The final sections show the following stats about your Q & A (query) with the DNS server:

  1. DNS query time
  2. DNS server name used for query
  3. Date and time of query

To hide the statistics about the query pass the +nostats option to dig command as follows:

dig +nostats www.cyberciti.biz
dig +nostats google.com

Hiding everything except the final answer

Pass the +short option to dig command as follows:

dig +short www.cyberciti.biz

Sample outputs:

75.126.153.206

See dig(1) for more information.

Examples and usage: Linux and Unix dig Command Examples