Home Linux Tools

dig – Linux DNS Lookup utility cheat sheet

by

in Linux, Tools

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, 8.8.8.8 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 8.8.8.8” > /etc/resolv.conf

Lookup different DNS records type using ‘dig’ :

Sample usage :

dig @dns-server example.com record-type

dig @8.8.8.8 hackersgarage.com A

Simple lookup :
dig hackersgarage.com

Lookup Name Servers
dig @8.8.8.8 hackersgarage.com NS

Lookup using external DNS Server.
dig @8.8.8.8 hackersgarage.com

Lookup MX record
dig @8.8.8.8 hackersgarage.com MX

Lookup CNAME record
dig @8.8.8.8 hackersgarage.com CNAME

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

Related Posts:

Previous post:

Next post: