Anatomy of a simple dig result

The 'dig' (Domain Information Gropper) command is one of the tool which is frequently used to troubleshoot DNS and BIND configurations. Its main purpose is to perform DNS lookups and query DNS servers. Though the subject is vast, i decided to blog some DNS stuffs under the 'Bind and DNS tools' category which i just created. I will keep on updating this article as i keep on finding interesting dig commands.

Screenshot from 2015-11-08 15:45:52

Lets analyze the result from a simple dig You would have a result similar to this one (In green). By default dig perform query A record when launched without any arguments.

1.I made a dig on my linux terminal

[[email protected] ~]# dig

2. The header section starts here. Several files in /etc/* is being read and the dig command will also launch a uname with the argument sys and node. The uname is already inbuilt in the code of the dig command. It then reads the /etc/resolv.conf

; <<>> DiG 9.9.4-RedHat-9.9.4-18.el7_1.5 <<>>

3. The ;; global options: +cmd is referred to the default arguments sets by dig to use only the the +cmd variables.  The opcode value is always static. The status is to inform us if any error occurred during the query. Each query is also associated with an id number ( ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 35133).

The flags qr (query response), rd (recursion desired) and ra (recursion available) are also information retrieved from the DNS header. As per the IETF RFC1035, when a dig with the default arguments is performed it will flag the qr, rd, ra and when the bit is 1 its a response and 0 for a query. Therefore 'qr' appears as 1

The ANSWER:2 is the numbers of answers received in the Answer section, same for QUERY, AUTHORITY and ADDITIONAL.

 ;; global options: +cmd
 ;; Got answer:
 ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 35133
 ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0

4. The "question section" is what you are querying for. In this case, a dig has been done on the A record. An A record simply means Adress i.e; the address associated with the website. We have several DNS records types which i will elaborate in future articles.

 ;            IN    A

5. The number 173 is the TTL (Time To Live), IN refers to Internet i.e the class in which it is. TTL  is a 32 bit signed integer which correspond to the time interval a record can be cached before the information is again queried. A TTL zero is used for extremely volatile data.

To resume we read it as follows: has a 173 seconds Time To Live on the Internet with the IP Address

;; ANSWER SECTION:        173    IN    A        173    IN    A

6. This section acts like a stat section. Information is given about the time it takes to query. The server IP address i.e; and the port number 53 which is associated with it. The date and finally the message size received is 204 bytes.

;; Query time: 22 msec
 ;; WHEN: Sun Nov 08 01:19:23 EST 2015
 ;; MSG SIZE  rcvd: 204

More analysis can be performed by launching a strace in front of a dig command. The RFC 1035 is also of great help. You can also check out the Internet System Consortium (ISC) website for more details.


  • dig -t MX will show you in the list of MX records in the 'Answer Section'
  • A  dig result is compose of only 5 parts i.e; Header, Question (question for the name server), Answer (resource records answering the question ), Authority (resource records pointing towards an authority) and Additional (resource records holding additional information).
  • To filter information from a default dig command you can use dig +nocomments +noauthority +noadditional +nostats which will give you only the answer. With an additional +noanswer wont give you anything.
  • However, the reverse way to filter dig results with a specific answer can be dig +noall +answer will give you only the answer section.