Friday, January 22, 2016

dig Examples

Below are a couple of examples on how you can use dig. These are common examples and include queries such as mail exchange lookup, address record lookup, reverse dns lookup, etc.
you can always add the  '+short' option at the end of any dig command to keep the output manageable:

eg dig +short

Perform a Basic DNS Dig
This is simply going to tell us what the IP address is for the domain The output will be an IP address which will be something like


Reverse DNS Dig
Perform a reverse DNS dig lookup. This will translate an IP address into its domain name. The output will be a domain name such as

dig -x

Dig MX Record Lookup
An MX (Mail Exchange) record tells us that the record is a domain name that is responsible for accepting email. The below command will tell us what domain name the mail record below is pointing as well as the priority of the mail records. . The output will be the domain name the record points to such as, which tells us that the mx record resolves to

dig -t MX

Show the TXT or SPF records

dig txt

Directly Query A DNS Server
By default the dns query will resolve off of your own dns server (which is usually the dns server of your ISP or local server), however we can manually specify the dns server we want to query by adding to the dns dig command.


Directly Query the TXT records of a  specific name server
dig txt

Show the Name servers of a domain
Here's how to query for a list of nameservers for a given domain,

dig ns

dig traceroute information
If you like the traceroute command, you can do something similar with dig to follow DNS nameservers, like this, using the

dig  +trace

 or to keep the output manageable:

dig  +trace +short