~2 min read • Updated Jul 21, 2025
1. What Is dig?
dig is a command-line utility used to send DNS queries to nameservers and display structured responses. It’s often preferred over nslookup for its flexibility and detailed output.
2. Installing dig on Linux
Included in packages like dnsutils or bind-utils:
sudo apt install dnsutils # Debian / Ubuntu
sudo yum install bind-utils # CentOS / RHEL3. Basic Usage
Query a domain:
dig example.com
Output includes sections: HEADER, QUESTION, ANSWER, AUTHORITY, and ADDITIONAL.
4. Common Record Types
- A record: IPv4 address
dig example.com A
dig example.com AAAA
dig example.com MX
dig example.com NS
dig example.com TXT
5. Useful Switches and Flags
| Option | Purpose | Example |
|---|---|---|
| +short | Display compact output | |
| +noall +answer | Show only answer section | |
| @server | Specify DNS server | |
| -x | Reverse lookup for IP | |
| +trace | Trace from root servers | |
6. Checking SOA and TTL
View Start of Authority and TTL values:
dig example.com SOA
dig example.com +noall +answer +ttl7. Reverse DNS Lookup
Find hostname associated with an IP:
dig -x 8.8.8.88. Practical Use Cases
- Verify DNS settings for domains
- Troubleshoot name resolution failures
- Validate SPF/DKIM TXT records
- Trace DNS resolution hierarchy
9. Conclusion
dig is an essential utility for domain analysis and DNS diagnostics in Linux. With support for granular queries, server specification, and filtered output, it empowers admins, developers, and analysts to audit DNS behavior efficiently.
Written & researched by Dr. Shahin Siami