dig Command
The dig command is a flexible DNS lookup tool that queries DNS servers to resolve domain names and retrieve various types of DNS records. It's widely used for DNS troubleshooting and network diagnostics.
Syntax
Description
The dig command performs DNS lookups and displays the results in a detailed format. It can query different types of DNS records and use specific DNS servers for queries.
Key features:
- Query various DNS record types (A, AAAA, MX, NS, CNAME, etc.)
- Perform reverse DNS lookups
- Use specific DNS servers for queries
- Trace DNS resolution path
- Batch processing of multiple queries
Common Options
| Option | Description |
|---|---|
+short |
Show only the answer section |
+trace |
Trace the delegation path |
+noall +answer |
Show only answer records |
-x |
Reverse lookup (IP to domain) |
-4 |
Use IPv4 only |
-6 |
Use IPv6 only |
-p port |
Use specific port number |
-t type |
Query specific record type |
Examples
Basic DNS lookup
Performs a basic DNS lookup for google.com
Short answer format
Shows only the IP address result
Query specific record type
Queries MX (mail exchange) records for google.com
Query NS records
Queries name server records
Query CNAME records
Queries canonical name records
Reverse DNS lookup
Performs reverse lookup to find domain for IP address
Use specific DNS server
Queries google.com using Google's DNS server
Trace DNS resolution
Shows the complete DNS resolution path
Query all record types
Attempts to retrieve all available record types
Query with clean output
Shows only the answer section without headers