Networking

dig & nslookup CLI

dig and nslookup commands for DNS troubleshooting.

32 commands
Windows MacOS Linux
#dns #troubleshooting

Basic Queries

Query DNS for A record
dig example.com
Show only the answer
dig example.com +short
Query using specific DNS server
dig @8.8.8.8 example.com
Show only answer section
dig example.com +noall +answer
Trace full DNS resolution path
dig example.com +trace

Record Types

Query A record for IPv4 address
dig example.com A
Query AAAA record for IPv6 address
dig example.com AAAA
Query MX record for mail servers
dig example.com MX
Query NS record for name servers
dig example.com NS
Query TXT records
dig example.com TXT
Query CNAME alias record
dig example.com CNAME
Query SOA record for zone info
dig example.com SOA

Advanced dig

Query with DNSSEC validation
dig example.com +dnssec
Reverse DNS lookup by IP
dig -x 93.184.216.34
Query all record types
dig example.com ANY +noall +answer
dig +nocmd example.com +noall +answer +ttlid # Clean output with TTL
Show query statistics
dig example.com +stats
Batch query from file
dig -f domains.txt +short

nslookup

Basic DNS lookup
nslookup example.com
Query using specific DNS server
nslookup example.com 8.8.8.8
Query MX records
nslookup -type=MX example.com
Query nameserver records
nslookup -type=NS example.com
Query TXT records
nslookup -type=TXT example.com
Query SOA record
nslookup -type=SOA example.com

Reverse Lookup

Reverse lookup for Google DNS
dig -x 8.8.8.8
Reverse lookup with nslookup
nslookup 8.8.8.8
Short reverse lookup output
dig -x 8.8.8.8 +short
Reverse lookup using host command
host 8.8.8.8
Reverse lookup for IPv6 address
dig -x 2001:4860:4860::8888

Quick Commands

Trace full DNS resolution path
dig example.com +trace
Perform reverse DNS lookup by IP address
dig -x 8.8.8.8
Query MX records for mail servers
nslookup -type=MX example.com