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.
Included in packages like dnsutils
or bind-utils
:
sudo apt install dnsutils # Debian / Ubuntu
sudo yum install bind-utils # CentOS / RHEL
Query a domain:
dig example.com
Output includes sections: HEADER, QUESTION, ANSWER, AUTHORITY, and ADDITIONAL.
dig example.com A
dig example.com AAAA
dig example.com MX
dig example.com NS
dig example.com TXT
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 |
|
View Start of Authority and TTL values:
dig example.com SOA
dig example.com +noall +answer +ttl
Find hostname associated with an IP:
dig -x 8.8.8.8
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.