dig
dig (Domain Information Groper) is a powerful command-line DNS lookup tool used to query DNS name servers and retrieve resource records.
It is commonly used in reconnaissance to resolve hostnames, enumerate DNS records, test custom name servers, and analyze DNS responses in detail.
Common Options
Basic Queries
Option |
Description
|
A |
Query IPv4 address record
|
AAAA |
Query IPv6 address record
|
MX |
Query mail exchange record
|
NS |
Query authoritative name servers
|
CNAME |
Query canonical name record (alias)
|
SOA |
Query start of authority record
|
TXT |
Query text records (commonly used for SPF, DKIM, etc.)
|
Query Control
Option |
Description
|
@[SERVER] |
Specify DNS server to query
|
+short |
Return simplified output (good for scripts)
|
+noall |
Suppress all sections of the output
|
+answer |
Show only the answer section
|
+timeout=[SEC] |
Set query timeout in seconds
|
+tries=[NUM] |
Set number of query attempts
|
+tcp |
Use TCP instead of UDP for the query
|
+nocomments |
Omit comments from output
|
Examples
Query A Record
↑ Options
Query AAAA Record
↑ Options
Query MX Records
↑ Options
Query Name Servers
↑ Options
Query CNAME Record
dig CNAME www.example.com
↑ Options
Query SOA Record
↑ Options
Query TXT Records
↑ Options
Use Specific DNS Server
dig @8.8.8.8 A example.com
↑ Options
Simplified Output
↑ Options
Show Only Answer Section
dig +noall +answer A example.com
↑ Options
Set Timeout
dig +timeout=2 A example.com
↑ Options
Set Number of Retries
dig +tries=1 A example.com
↑ Options
Force TCP Query
↑ Options
See Also