Querying and Diagnosing DNS Records with the dig Command
What Will You Learn in This Guide?
In this guide, you will learn how to query DNS records with the dig command.
You will also see how to diagnose DNS configurations by reading the dig output.
Technical Summary
Main Technical Topic: DNS query and diagnosis
Solved Problem: Checking the accuracy of domain name DNS records
Scope: dig setup, common commands, output analysis
dig is the essential DNS diagnostic tool for system administrators.
###dig What is it?
dig (Domain Information Groper) is part of the BIND package.
It allows you to make DNS queries from the command line.
You can obtain the following information:
- A, AAAA, MX, NS records
- Authoritative name servers
- DNS delegation chain
dig Setup
Linux (Ubuntu/Debian)
The dig usually comes in the dnsutils package.
sudo apt update
- This command updates the package list.
sudo apt install dnsutils
- This command installs the dig tool.
1. Verify the installation:
dig -v
- This command shows the dig version.
#####macOS
- On macOS dig is installed most of the time.
dig -v
- This command returns version information.
If not installed, install it with Homebrew:
brew install bind
- This command installs BIND and dig.
#####Windows
-
On Windows, dig is installed with the BIND 9 package.
-
Select Tools Only in the installation
-
Add bin folder to PATH
Example path:
C:\Program Files\ISC BIND 9\bin
- Test the installation:
dig -v
Frequently Used dig Commands
| Command | Sample Usage | Description |
|---|---|---|
dig <alan> | dig ornek.com | Returns the A record (IP address) for the domain |
dig <alan> any | dig ornek.com any | Lists all DNS records for the domain |
dig <alan> MX | dig ornek.com MX | Shows mail (MX) servers of the domain |
dig @<ns> <alan> | dig @8.8.8.8 ornek.com | Queries via specific DNS server |
dig <alan> +short | dig ornek.com +short | Returns only IP addresses as plain output |
dig <alan> +trace | dig ornek.com +trace | Shows step by step the delegation chain from the root of the DNS query |
2. How to Read dig Output?
- A dig query returns more than one partition.
QUESTION SECTION
1. Shows the DNS query sent. 2. Specifies which record type is requested.
ANSWER SECTION
1. Contains the actual DNS response. 2. It is generally the most important section.
AUTHORITY SECTION
1. Lists the authorized name servers of the domain name. 2. Used for delegation control.
ADDITIONAL SECTION
1. Contains additional IP information. 2. Usually NS records have A addresses.
Frequently Asked Questions (FAQ)
1. What is the difference between dig and ping? ping tests the connection, dig queries DNS records.
2. When to use +short? Ideal for using the output in scripts.
3. What does status: NOERROR mean? It means the DNS query was answered without errors.
4. How do I query MX records? Use the digyourdomain.com MX command.
5. Can another server be queried instead of ISP DNS? Yes. It can be specified like @8.8.8.8.
Result
-dig is the clearest way to understand DNS configuration.
- Quickly shows incorrect records and delegation issues.
You can safely use this tool on the GenixNode platform to test your DNS and server infrastructure.

