Checking DNS records with the command dig


DNS stands for Domain Name System and resolves domain names into ip-addresses.

There are 3 main records that DNS holds for each domain - A, CNAME and MX records

The A record holds the ip-address for the domain, the CNAME record holds one or more aliases for the same computer and the MX is the Mail Exchange record and is used to tell mail servers how to route email for this domain.

The command dig is used for querying DNS and is very useful for troubleshooting DNS issues

To query the record for a domain use dig with the domain as the parameter, for example typing the following


will query the DNS server listed in your resolv.conf file and display the A records for, the output that is returned from the DNS server will be something like the following

; <<>> DiG 9.3.2 <<>>
[1]  ;; global options:  printcmd
[2]  ;; Got answer:
[3]  ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20738
[4]  ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2

[6]  ;          IN      A

[8]   10800   IN      A

[10]       172800  IN      NS
[11]       172800  IN      NS

[13]       8228    IN      A
[14]       60725   IN      A

[15] ;; Query time: 126 msec
[16] ;; SERVER:
[17] ;; WHEN: Fri Feb  6 13:27:26 2009
[18] ;; MSG SIZE  rcvd: 135

The numbering at the beginning of each line is there to help with the explanation and are not part of the output.

The lines beginning with ;; are comments.

Line [1] shows the version of dig (9.3.2), plus the command line options (

Line [2] gives the query options (printcmd) which just means print these top two lines.

Lines [3] and [4] display the header of the response it received from the DNS server with its various options.
opcode: QUERY shows that this was a standard query, and status: NOERROR shows there were no errors.
The flags displayed on line [4] have the following meaning: qr = query, rd = recursion desired, ra = recursion available.

Lines [5] and [6] are the question section and show us details of the query, in this case the A record (ip-address) of and that it is in the internet class denoted by IN.

Lines [7] and [8] are the answer section and show that has the ip-address .

Lines [9], [10] and [11] are the authority section and show which name servers (NS) have authority for this domain and can provide an authoritative answer. In this case there are two such servers and .

Lines [12], [13], [14] are the additional section and display the ip-addresses for each of the name servers in the authority section.

Lastly lines [15] to [18] provide some stats about the query, the time it took, the ip-address of the server the query originated from, the date and time of the query and the size of the query.