Support Online
Skip to main content

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

  1. On Windows, dig is installed with the BIND 9 package.

  2. Select Tools Only in the installation

  3. Add bin folder to PATH


Example path:


C:\Program Files\ISC BIND 9\bin
  • Test the installation:


dig -v

Frequently Used dig Commands

CommandSample UsageDescription
dig <alan>dig ornek.comReturns the A record (IP address) for the domain
dig <alan> anydig ornek.com anyLists all DNS records for the domain
dig <alan> MXdig ornek.com MXShows mail (MX) servers of the domain
dig @<ns> <alan>dig @8.8.8.8 ornek.comQueries via specific DNS server
dig <alan> +shortdig ornek.com +shortReturns only IP addresses as plain output
dig <alan> +tracedig ornek.com +traceShows 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.