Linux dig Command: Query DNS Records in Detail
dig queries DNS servers and shows detailed information about records such as A, AAAA, MX, TXT, and response status. It is used to diagnose name resolution issues or compare answers from specific DNS servers.
What is the dig command?
The default query is usually an A record, and the results are read separately in the ANSWER SECTION and status. +short shows only a simplified result, which may lose context such as status, authority, and TTL. DNS responses may vary depending on caching and the server used.
Basic syntax
dig [@DNS server] name [record type] [option]
The installed implementation and options may vary depending on the distribution. Check the description for the current system with man dig.
Examples
Checking A records
Look at the domain's IPv4 address and response status.
dig example.com A
Checking mail server records
Check the priority and host of MX records.
dig example.com MX
View only brief answers
Can be used for scripts or quick checks, but diagnostic information is reduced.
dig +short example.com A
Reading Each Field of a DNS Response
dig shows DNS (Domain Name System) queries in detail. +noall +answer keeps only the answer section, making it easier to see the record name, TTL, class, type, and value.
dig +noall +answer example.com A
Example output format (IP and TTL may differ from the actual response):
example.com. 300 IN A 192.0.2.10
300 is the TTL in seconds, IN is the Internet class, and A is the IPv4 address record. If there is no answer, check the query status (such as NXDOMAIN), the queried server, and the record type. When comparing responses from multiple DNS servers, specify @server_address.
Main Options and Format
| Options/Format | Description |
|---|---|
@server |
Specifies the DNS server to query. |
A / AAAA / MX / TXT |
Specifies the type of record to query. |
+short |
Outputs only short answers. |
+noall +answer |
Outputs centered on the answer section. |
-x address |
Performs a reverse DNS query. |
+trace |
Queries along the delegation path. |
Precautions when using
Even if the +short result is empty, you cannot distinguish between NXDOMAIN, NODATA, server errors, or timeouts, so check the status of the full response. dig queries DNS directly and may differ from the application's full name resolution path. Check /etc/hosts or local cache issues separately.
Frequently Asked Questions
Why are dig results different from browser access results?
dig shows the record response from the selected DNS server, but browsers may use local cache, proxies, /etc/hosts, or other resolution paths.
Official Documentation
For the exact behavior of options and implementation differences, refer to the official dig documentation.









