CentOS 7 dig command not found – How to install dig on CentOS

I deployed CentOS 7 Linux minimal in the cloud. However, I am unable to find the dig command on my newly created CentOS 7 server. It says ‘-bash: dig: command not found‘ I tried yum install dig, but it failed. How do I install dig command on CentOS 7 Linux using the command line?

Introduction: The dig command is primarily used to query DNS servers. It is a useful tool for network troubleshooting and DNS/domain issues. It is popular due to its flexibility, simple to use, and crystal clear output over host command. This page shows how to install dig command on a CentOS Linux 7 using the bash shell. You must log in as root user to install the following package.

CentOS 7 dig command not found

You may get the following error when you run dig command:
$ dig www.cyberciti.biz
$ dig +short myip.opendns.com @resolver1.opendns.com

Try to locate the dig with type command:
$ type -a dig
Display your PATH settings on Linux with help of echo command:
$ echo "$PATH"
CentOS 7 dig command not found

Getting rid of “-bash: dig: command not found”

BIND (Berkeley Internet Name Domain) is an implementation of the DNS (Domain Name System) protocols. BIND includes a DNS server (named), which resolves host names to IP addresses; a resolver library and tools for verifying that the DNS server is operating properly. However, bind is not installed by default including the dig command.

You must install bind-utils package. It contains a collection of utilities (such as dig command and other) for querying DNS name servers to find out information about internet hosts. These tools will provide you with the IP addresses for given host names, as well as other information about registered domains and network addresses.

How to install dig on CentoS 7

You must install bind-utils if you need to get information from DNS name servers. Use the yum command:
$ sudo yum install bind-utils

How do I use dig command?

The syntax is:
dig Hostname
dig DomaiNameHere
dig @DNS-server-name Hostname
dig @DNS-server-name IPAddress
dig @DNS-server-name Hostname|IPAddress type

For example:
$ dig www.cyberciti.biz
$ dig @ bash.cyberciti.biz
$ dig @ MX cyberciti.biz
$ dig @ AAAA cyberciti.biz

dig command installed on a CentOS Linux 7 and displaying dns output of a query

A few more examples:
# find txt records #
dig txt www.cyberciti.biz
# locate cname #
dig cname mail.cyberciti.biz

A tip about finding package names

Want to find out which package owned dig command on a CentOS Linux 6/7? Try:
# yum whatprovides '*bin/dig'

The above command indicates that /usr/bin/dig command provided by bind-utils package.


And there you have it, dig command installed and working correctly on a CentOS Linux 7. You can use the same command on a CentOS Linux 6.x to install dig command.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 1 comment so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
1 comment… add one
  • Batsuuri Magsarjantsa Aug 31, 2020 @ 3:34

    Great !

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum