~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 / RHEL

3. 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
  • AAAA: IPv6 address
  • dig example.com AAAA
  • MX: Mail exchange servers
  • dig example.com MX
  • NS: Nameservers
  • dig example.com NS
  • TXT: Text records (e.g., SPF)
  • dig example.com TXT

5. Useful Switches and Flags


OptionPurposeExample
+shortDisplay compact output
dig example.com +short
+noall +answerShow only answer section
dig example.com +noall +answer
@serverSpecify DNS server
dig example.com @8.8.8.8
-xReverse lookup for IP
dig -x 93.184.216.34
+traceTrace from root servers
dig example.com +trace

6. Checking SOA and TTL


View Start of Authority and TTL values:

dig example.com SOA
dig example.com +noall +answer +ttl

7. Reverse DNS Lookup


Find hostname associated with an IP:

dig -x 8.8.8.8

8. 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