How to Install dig on CentOS 7 and 8

October 7, 2020

Introduction

The dig (Domain Information Groper) command is a DNS lookup utility. It’s often used by system and network administrators to collect Domain Name Server information. Apart from collecting data, the dig command is a useful tool for network troubleshooting and solving DNS issues.

You can use this DNS testing tool on Linux, Mac OS, and Windows. While most newer distros have dig pre-installed, you could find yourself needing to do this.

In this tutorial, learn how to install dig on your CentOS and some basic dig commands.

How to install the dig command on CentOS.

Prerequisites

  • A Linux system with CentOS
  • A user account with sudo or root privileges
  • Access to a terminal window/command line

Note: If you are looking for instructions for Windows, refer to our post How to Install Dig on Windows.

How to Install dig on CentOS

If dig is unavailable on your RHEL/CentOS Linux system, you can install it using one simple command:

sudo yum install bind-utils

Or:

sudo dnf install bind-utils

The command installs the bind-utils package, a collection of utilities that include dig and other DNS querying.

Note: Want to learn more about Domain Name Systems? Take a look at what DNS is, how it works, and why it is important to flush DNS cache.

Check dig Version

To verify you have successfully installed dig, prompt the system to display the version of dig on the system:

dig -v

If dig is available, it shows the utility’s version number, as in the image below.

Check dig version on CentOS.

If you don’t have dig, the output responds with the message: dig command not found.

Basic dig Command CentOS Examples

Below you can find some of the most common dig commands and examples showing how they work.

Check DNS Record for a Specific Domain

To check the DNS record for a specific domain, run the command:

dig [domain_name]

For example:

dig phoenixnap.com

The output should display the following information:

  • the version of the dig command
  • technical information provided by the DNS nameserver
  • the QUESTION section
  • and the ANSWER section (the IP address)

By default, you are requesting the A record (the record that points your hostname to an IP address).

Basic dig command example.

Check IP Address

If you want to see just the IP address (the answer section), run:

dig [domain_name] +short

The output gives you the IP address for the specified domain, without the additional information.

Use the dig command with the +short option to display just the IP address of the domain.

Check MX Record

You can use the dig command to find the domain’s MX (Mail Exchange) records. To display the MX records, use:

dig [domain_name] MX

To display just the mail server, without the additional information, add the +short option:

dig [domain_name] MX +short
Use dig command to display MX records.

Check SOA Record

To find the authoritative DNS server, use the dig command to display the SOA (Start of Authority) record. This information tells you core information and parameters for your DNS zone.

Use the utility to display the detailed SOA record by running:

dig [domain_name] SOA
Run dig command to display SOA record.

Alternatively, add the +short option for the concise output:

dig [domain_name] SOA

Note: For more dig commands, refer to the article How to Use the Linux dig Command.

Conclusion

After reading this tutorial, you should have dig installed on CentOS. Additionally, you should know some basic dig commands and how to use them.

Was this article helpful?
YesNo
Sofija Simic
Sofija Simic is an experienced Technical Writer. Alongside her educational background in teaching and writing, she has had a lifelong passion for information technology. She is committed to unscrambling confusing IT concepts and streamlining intricate software installations.
Next you should read
How to Use Linux dig Command (DNS Lookup)
May 23, 2024

dig (Domain Information Groper) command is a tool for querying DNS name servers. It is a helpful command for...
Read more
Ultimate Guide to Types of SSL Certificates
August 20, 2020

While they all encrypt data, not all SSL certificates provide the same features to their users. Learn about...
Read more
How to Configure CentOS Network Settings
March 25, 2020

Configure CentOS network settings using the command line or the Network Manager TUI. This guide shows you how...
Read more
How to Install and Use Nmap Network Scanner on Linux
April 8, 2024

Learn how to install Nmap on a Linux based system and use it to retrieve valuable information from remote...
Read more