Skip to Content

Dig

dig (Domain Information Groper) queries DNS servers and returns detailed information about DNS records. It is the standard tool for DNS troubleshooting on Linux.

Basic Lookup

# Look up the A record for a domain dig example.com # Short output — just the answer dig example.com +short

Query Specific Record Types

dig example.com A # IPv4 address dig example.com AAAA # IPv6 address dig example.com MX # Mail exchange dig example.com TXT # TXT records (SPF, DKIM, etc.) dig example.com NS # Name servers dig example.com CNAME # Canonical name dig example.com SOA # Start of authority

Query a Specific DNS Server

# Query Cloudflare's DNS dig @1.1.1.1 example.com # Query Google's DNS dig @8.8.8.8 example.com # Useful for comparing responses between DNS servers dig @1.1.1.1 example.com +short dig @8.8.8.8 example.com +short

Reverse Lookup

# Resolve an IP address back to a hostname dig -x 8.8.8.8 # Short output dig -x 8.8.8.8 +short

Trace the Full Resolution Path

# Follow the full delegation chain from root servers down dig example.com +trace

Check DNS Propagation

After making DNS changes, compare responses across multiple resolvers to verify propagation:

for server in 1.1.1.1 8.8.8.8 9.9.9.9; do echo "=== $server ===" dig @$server example.com A +short done
Last updated on