Linux Tips: Using the dig Command for DNS Queries
The dig command is a powerful DNS lookup utility that helps you query DNS servers and troubleshoot DNS-related issues.
Basic Usage
Here are some common ways to use the dig command:
# Basic DNS lookup
dig example.com
# Query specific record type
dig example.com MX
# Query specific DNS server
dig @8.8.8.8 example.com
# Short answer only
dig example.com +short
Useful Options
Some helpful dig command options:
- +short - Display brief output
- +nocomments - Remove comment lines
- +nocmd - Remove command line from output
- +nostat - Remove statistics
Common Record Types
- A - IPv4 addresses
- AAAA - IPv6 addresses
- MX - Mail servers
- NS - Nameservers
- TXT - Text records
- CNAME - Canonical names