dig (Domain Information Groper) is a flexible command-line tool for querying DNS name servers. It performs DNS lookups and displays the answers returned from the queried name servers.
# Simple A record lookup
dig example.com
# Query specific record type
dig example.com MX
dig example.com NS
dig example.com TXT
dig example.com AAAA
# Query all record types
dig example.com ANY
# Query using a specific DNS server
dig @8.8.8.8 example.com
dig @1.1.1.1 example.com
# Query the authoritative nameserver directly
dig @ns1.example.com example.com
# Short answer only
dig example.com +short
# Detailed output with comments
dig example.com +comments
# No additional info (cleaner output)
dig example.com +noall +answer
# Show all sections
dig example.com +noall +answer +authority +additional
# Show query time and server info
dig example.com +stats
# Check if DNS server is responding
dig @8.8.8.8 google.com +short
# Check TTL values
dig example.com +noall +answer +ttlid
# Query with timeout and retries
dig example.com +time=2 +tries=3
# Check SOA for zone info
dig example.com SOA +short
# Verify MX records
dig example.com MX +noall +answer
# Test for open resolver
dig @target-ip example.com
# Check for zone transfer vulnerability
dig AXFR @ns1.target.com target.com
# Enumerate DNS version (if exposed)
dig @ns1.target.com version.bind TXT CHAOS
dig @ns1.target.com hostname.bind TXT CHAOS
# Get just IP addresses
dig example.com +short
# Get nameservers only
dig example.com NS +short
# Get MX records with priority
dig example.com MX +noall +answer | awk '{print $5, $6}'