Dig – To query DNS and see the records it holds, you can use a software tool called dig that queries DNS servers directly. Dig comes standard with all the major Linux distributions, and is useful for verifying and troubleshooting DNS problems.
To check the record for your domain, run dig with your domain name as the parameter. For example:
cyborg@cyborg:~$ dig www.ztrela.com
This command causes dig to look up the A record for the domain name www.hungrypenguin.net. To do this dig starts by looking in your /etc/resolv.conf file and querying the DNS servers listed there. The response from the DNS server is what dig displays:
cyborg@cyborg:~$ dig www.ztrela.com ; <<>> DiG 9.9.5-3ubuntu0.1-Ubuntu <<>> www.ztrela.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 6580 ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;www.ztrela.com. IN A ;; ANSWER SECTION: www.ztrela.com. 13947 IN CNAME ztrela.com. ztrela.com. 13947 IN A 220.127.116.11 ;; Query time: 35 msec ;; SERVER: 127.0.1.1#53(127.0.1.1) ;; WHEN: Mon Aug 31 13:51:48 IST 2015 ;; MSG SIZE rcvd: 73
Lines beginning with ; are comments that are not part of the information received from the DNS server, but 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.9.5), the command line parameters (
www.ztrela.com) and the query options (
printcmd option means that the command section (the name given to these first two line) is printed. You can turn it off by using the option
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 one answer, two pieces of information in the authority section, and a further two 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, which simply tells us the query, which in this case is a query for the A record of www.ztrela.com. The
IN means this is an Internet lookup (in the Internet class).
The answer section tells us that www.ztrela.com has the IP address 18.104.22.168.
Along with the IP address the DNS record contains some other useful information. The authority section contains a list of name servers that are responsible for the domain name — those that can always give an authoritative answer. Here we find two name servers listed, which are the name servers of the company with which the domain was registered. To save an extra lookup, dig lists the IP addresses of those name servers in the additional section.
Lastly there are some stats about the query. You can turn off these stats using the
By default dig is quite verbose. One way to cut down the output is to use the
dig www.ztrela.com +short
which will drastically cut the output to:
However, for diagnosing DNS problems, you generally need fuller output. You can find a happy medium by putting the following lines into a file called .digrc in your home directory, you can user various commands too and check the output.
+nocmd +nostats +noquestion