dig Command
Intermediate Networking man(1)DNS lookup utility for querying name servers
👁 10 views
📅 Updated: Mar 15, 2026
SYNTAX
dig [@SERVER] NAME [TYPE]
What Does dig Do?
dig (Domain Information Groper) is a DNS lookup utility for querying DNS servers. It is the most comprehensive and widely used DNS diagnostic tool, providing detailed information about DNS records, response times, and server behavior.
dig can query any type of DNS record (A, AAAA, MX, NS, TXT, CNAME, SOA, etc.) and shows the complete DNS response including answer, authority, and additional sections. It supports querying specific DNS servers, setting query options, and performing reverse lookups.
dig is essential for DNS troubleshooting, verifying DNS propagation, checking domain configuration, and debugging email delivery issues (MX records).
dig can query any type of DNS record (A, AAAA, MX, NS, TXT, CNAME, SOA, etc.) and shows the complete DNS response including answer, authority, and additional sections. It supports querying specific DNS servers, setting query options, and performing reverse lookups.
dig is essential for DNS troubleshooting, verifying DNS propagation, checking domain configuration, and debugging email delivery issues (MX records).
Options & Flags
| Option | Description | Example |
|---|---|---|
| +short | Show only the answer (concise output) | dig +short google.com |
| -t | Specify record type (A, MX, NS, TXT, etc.) | dig -t MX gmail.com |
| @server | Query a specific DNS server | dig @8.8.8.8 example.com |
| +noall +answer | Show only the answer section | dig +noall +answer example.com |
| -x | Reverse DNS lookup (IP to hostname) | dig -x 8.8.8.8 |
| +trace | Trace DNS delegation from root servers | dig +trace example.com |
| +nssearch | Find authoritative nameservers | dig +nssearch example.com |
Practical Examples
#1 Basic DNS lookup
Shows the A record (IP address) with full DNS response details.
$ dig example.com#2 Quick IP lookup
Returns just the IP address without any extra information.
$ dig +short example.com
Output:
93.184.216.34
#3 Look up MX records
Shows mail exchange records — essential for email troubleshooting.
$ dig -t MX gmail.com +short
Output:
5 gmail-smtp-in.l.google.com.\n10 alt1.gmail-smtp-in.l.google.com.
#4 Query specific DNS server
Queries Google's public DNS instead of your default resolver.
$ dig @8.8.8.8 example.com#5 Check TXT records (SPF/DKIM)
Shows TXT records including SPF, DKIM, and domain verification entries.
$ dig -t TXT example.com +short#6 Reverse DNS lookup
Looks up the hostname for an IP address.
$ dig -x 8.8.8.8 +short
Output:
dns.google.
#7 Trace DNS resolution
Shows the complete DNS resolution path from root servers to the final answer.
$ dig +trace example.comTips & Best Practices
Check DNS propagation: Query different DNS servers to check propagation: dig @8.8.8.8 domain.com vs dig @1.1.1.1 domain.com. Different results mean propagation is incomplete.
dig vs nslookup: dig provides more detailed output and is preferred by professionals. nslookup is simpler but deprecated on some systems. dig is the standard DNS diagnostic tool.
Cached results: Your local resolver caches DNS responses. Query external servers (8.8.8.8, 1.1.1.1) to bypass local caching when testing changes.
Frequently Asked Questions
How do I look up the IP address of a domain?
Use dig +short domain.com for just the IP, or dig domain.com for full details.
How do I check MX records for email?
Use dig -t MX domain.com to see mail exchange records. The lower priority number means higher preference.
How do I query a specific DNS server?
Use dig @server domain.com. For example: dig @8.8.8.8 example.com queries Google DNS.
Related Commands
More Networking Commands
Master Linux with Professional eBooks
Curated IT eBooks covering Linux, DevOps, Cloud, and more
Browse Books →