Linux Tools

dig – Linux DNS Lookup utility cheat sheet

digDomain Information Groper is a light weight Linux utility for querying DNS records. It is widely used to diagnose DNS servers, troubleshoot DNS servers, purge DNS Cache using external DNS server and dozen of great features it provides.

Here i am sharing quick cheat sheet of dig – DNS Lookup utility that every System/Network administrator should have print out at their desk.

In our examples, is a Google Public DNS Server that can be use in /etc/resolv.conf

Why to use Google Public DNS ?

If you have a DNS record with high ttl e.g 3600 seconds, your local DNS server may not purge the old record from the cache. So better you use Google public DNS server to resolve it most recent update record.

You may also be interested to read about namebench – DNS benchmarking utility from Google

To set google public dns as default resolver, run below command;

NOTE : This will override your resolv.conf

echo “nameserver” > /etc/resolv.conf

Lookup different DNS records type using ‘dig’ :

Sample usage :

dig @dns-server record-type

dig @ A

Simple lookup :

Lookup Name Servers
dig @ NS

Lookup using external DNS Server.
dig @

Lookup MX record
dig @ MX

Lookup CNAME record
dig @ CNAME

Look TXT record (e.g will it will return SPF records, google verification methods)
dig @ TXT