Feb 182013
 

An interesting small and quick, cheat sheet for the command dig found on http://www.hackersgarage.com/

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 these examples, 8.8.8.8 is a Google Public DNS Server that you can 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


Popular Posts:

Flattr this!

  One Response to “dig – Linux DNS Lookup utility cheat sheet”

  1. You also can use +short to get terse answer:
    $ dig @8.8.8.8 google.com +short A
    74.125.234.103
    74.125.234.105
    74.125.234.99
    74.125.234.104
    74.125.234.101
    74.125.234.98
    74.125.234.100
    74.125.234.110
    74.125.234.97
    74.125.234.96
    74.125.234.102

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

*