Cheatsheet: dig
Basic Domain Name Lookup
Example Usage:
dig example.com
What it does: This operation performs a basic DNS lookup for the specified domain name, retrieving its IP address and associated records.
Command-line Arguments Explained:
example.com: The domain name to be looked up.
Retrieve NS Records
Example Usage:
dig +nsexample.com
What it does: This operation retrieves the Name Server (NS) records for the specified domain name, which are used to map the domain to its DNS servers.
Command-line Arguments Explained:
+ns: Option to retrieve NS recordsexample.com: The domain name for which to retrieve NS records.
Retrieve MX Records
Example Usage:
dig +mx example.com
What it does: This operation retrieves the Mail Exchanger (MX) records for the specified domain name, which are used to route email to the domain's mail servers.
Command-line Arguments Explained:
+mx: Option to retrieve MX recordsexample.com: The domain name for which to retrieve MX records.
Retrieve SOA Records
Example Usage:
dig +soa example.com
What it does: This operation retrieves the Start of Authority (SOA) records for the specified domain name, which contain information about the domain's DNS zone.
Command-line Arguments Explained:
+soa: Option to retrieve SOA recordsexample.com: The domain name for which to retrieve SOA records.
Perform a Reverse DNS Lookup
Example Usage:
dig -x 8.8.8.8
What it does: This operation performs a reverse DNS lookup for the specified IP address, retrieving the domain name associated with it.
Command-line Arguments Explained:
-x: Option to perform a reverse DNS lookup8.8.8.8: The IP address to be looked up.
Retrieve AAAA Records
Example Usage:
dig +aaaa example.com
What it does: This operation retrieves the IPv6 AA (Address Assignment) records for the specified domain name, which are used to map the domain to its IPv6 address.
Command-line Arguments Explained:
+aaaa: Option to retrieve AAAA recordsexample.com: The domain name for which to retrieve AAAA records.
Perform a Dig Axfr
Example Usage:
dig +axfr example.com
What it does: This operation performs a DNS zone transfer (AXFR) for the specified domain name, retrieving all records associated with the domain.
Command-line Arguments Explained:
+axfr: Option to perform a DNS zone transferexample.com: The domain name for which to perform the zone transfer.
Set Query Type
Example Usage:
dig +inq example.com
What it does: This operation sets the query type to IN (Internet) and Q (Query) for the specified domain name, retrieving the IN and Q records.
Command-line Arguments Explained:
+inq: Option to set the query type to IN and Qexample.com: The domain name for which to set the query type.
Use a Specific DNS Server
Example Usage:
dig +server 8.8.8.8 example.com
What it does: This operation uses the specified DNS server to perform a lookup for the domain name.
Command-line Arguments Explained:
+server: Option to specify the DNS server8.8.8.8: The IP address of the DNS server to useexample.com: The domain name to be looked up.
Set Timeout
Example Usage:
dig +timeout 10 example.com
What it does: This operation sets the timeout for the DNS lookup to the specified number of seconds.
Command-line Arguments Explained:
+timeout: Option to set the timeout10: The number of seconds to wait for a responseexample.com: The domain name to be looked up.
Use a Specific Port
Example Usage:
dig +port 53 example.com
What it does: This operation uses the specified port to perform a lookup for the domain name.
Command-line Arguments Explained:
+port: Option to specify the port53: The port number to useexample.com: The domain name to be looked up.

