Skip to main content

dig Cheatsheet

By Dejan Panovski Updated on Download PDF

Quick reference for querying DNS records, tracing resolution, and debugging name resolution with dig

The `dig` command queries DNS name servers and prints detailed records such as A, AAAA, MX, NS, TXT, and PTR. This cheatsheet covers basic lookups, record type queries, output control, reverse lookups, trace and DNSSEC checks, and quick troubleshooting.

Basic Syntax

Core dig command forms.

CommandDescription
dig example.comLook up the A record using the default resolver
dig example.com @8.8.8.8Query a specific name server
dig example.com mxQuery a specific record type
dig -x 192.0.2.1Run a reverse DNS lookup
dig example.com +shortPrint only the answer value

Common Lookups

Quick checks for hostnames and addresses.

CommandDescription
dig example.comLook up A records using the default resolver
dig example.com +shortPrint only the IP address
dig www.example.comCheck a hostname or subdomain
dig example.com +noall +answerShow only the answer section
dig -x 192.0.2.1 +shortReverse lookup, hostname only

Record Types

Append the record type to query a specific record.

CommandDescription
dig example.com aQuery IPv4 address records
dig example.com aaaaQuery IPv6 address records
dig example.com mxQuery mail exchanger records
dig example.com nsQuery authoritative name servers
dig example.com txtQuery TXT records
dig example.com soaQuery the SOA record
dig www.example.com cnameCheck whether a hostname is an alias
dig example.com anyRequest an ANY response; many servers return limited data

Output Control

Trim the verbose default output.

CommandDescription
dig example.com +shortAnswer value only
dig example.com +noall +answerAnswer section only
dig +nocmd example.comDrop the version and options header
dig example.com +nocomments +nostatsHide comments and query stats
dig example.com +ttlunitsShow TTL values with units such as minutes or hours
dig example.com +multilinePrint records one field per line

Specific DNS Servers

Compare answers from different resolvers.

CommandDescription
dig example.com @8.8.8.8Query Google Public DNS
dig example.com @1.1.1.1Query Cloudflare DNS
dig example.com @9.9.9.9Query Quad9
dig example.com mx @8.8.8.8Query MX records from a specific resolver
dig example.com txt @1.1.1.1Compare TXT answers between resolvers

Trace, DNSSEC, and Bulk

Deeper debugging and batch queries.

CommandDescription
dig example.com +traceTrace resolution from the root servers down
dig example.com +dnssecRequest DNSSEC records; this does not validate them locally
dig example.com @1.1.1.1 +dnssec | grep flagsCheck whether the resolver returned the ad validation flag
dig example.com +tcpForce the query over TCP
dig -f domains.txt +shortBulk query domains from a file
dig -vPrint the dig version

Troubleshooting

Quick checks for common dig results.

IssueCheck
NXDOMAINDomain does not exist; verify spelling and registration
SERVFAILCheck DNSSEC, delegation, and authoritative-server availability; compare another resolver
REFUSEDThe server policy rejected the query; verify recursion access or query the proper authoritative server
connection timed out; no servers could be reachedCheck network and /etc/resolv.conf; try +tcp
Truncated replydig normally retries over TCP; use +tcp to test TCP directly

Use these guides for fuller DNS workflows.

GuideDescription
dig Command in LinuxFull dig guide with practical examples
nslookup CheatsheetSimpler interactive DNS lookups
ping CheatsheetQuick connectivity checks before DNS work
IP command cheatsheetInspect interfaces, addresses, and routes
curl CheatsheetTest HTTP reachability after DNS resolves