Have you ever wanted to query the Domain Name System (DNS) to discover what information it holds about your domain? Do you have some important changes to make to your DNS records and need a way to verify your changes? In this tutorial you will learn how to check your DNS records with a tool called dig.
DNS
DNS is an Internet service that translates domain names into IP addresses. Each time you use a domain name, DNS is used to translate the name into the corresponding IP address. To do the translation DNS holds records for each domain. There are theoretically over 50 different types of DNS record for the Internet. However the most important are the A, CNAME and MX records. The A record stores the host IP address. The CNAME is an alias record and the MX record is the mail exchange record which tells mail servers how to route the email. A full list of record types can be found at: http://www.iana.org/assignments/dns-parameters.
This tells us that www.newsforge.com is an alias for newsforge.com and that newsforge.com has the IP address 66.35.250.177. If you want to read the newsforge site with your web browser, your computer will query DNS for the IP address and then make a network connection (over the Internet) to the newsforge server and start downloading the pages.
Dig
To query DNS and see the records which it holds, you can use a tool called dig. Dig queries DNS servers directly and it comes as standard with all the major Linux distributions. Dig is a very useful tool for webmasters and site administrators to verify and troubleshoot DNS problems.
To check the record for your domain run dig with your domain name as the parameter. For example:
dig www.domain.com
This will cause dig to lookup the A record for the domain name www.hungrypenguin.net. To do this dig will look in your /etc/resolv.conf file and query the DNS servers listed there. The response from the DNS server is what is displayed:
The first thing to note is that lines beginning with ; are comments which do not make up part of the actual answer received from the DNS server, however they do reflect some of the low level protocol used in making the query.
The first two lines tell us the version of dig (9.2.4), the command line parameters (www.hungrypenguin.net ) and the query options (printcmd). The printcmd options means that the command section (the name given to these first two line) is printed. You can turn it off by using the option +nocmd.
Next dig shows the header of the response it received from the DNS server. Here it reports that an answer was obtained from the query response (opcode: QUERY) and that the response contains 1 answer, 2 pieces of information in the authority section and a further 2 in the additional section. The flags are used to note certain things about the DNS server and its response. For example, the RA flag shows that recursive queries are available.
Next comes the question section, this simply tells us the query, which in this case is a query for the A record of www.hungrypenguin.net. The IN means this is an Internet lookup (in the Internet class).
Now for the answer. The answer section tells us that www.hungrypenguin.net has the IP address 67.15.117.250.
Along with the IP address the DNS record contains some more useful information. In the authority section there is a list of name servers which are responsible for the domain name, those which can always give an authoritative answer. Here we find two name servers listed. These are in fact the name servers of the company with which the domain was registered. To save an extra lookup the IP addresses of those name servers are listed in the additional section.
Lastly there are some stats about the query. These stats can be turned off using the +nostats option.