How to install dig and host on CentOS 7


On CentOS 7 default, you can’t use dig or host command:

[root@tutorialspots ~]# dig
-bash: dig: command not found

How to install dig on CentOS 7?

The DIG tool and the HOST tool are a part of the BIND Utilities so you need to install them. To install the BIND Utilities, type the following:

yum install -y bind-utils

Result:

[root@tutorialspots ~]# yum install -y bind-utils
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: repos-tx.psychz.net
 * epel: kdeforge2.unl.edu
 * extras: centos.den.host-engine.com
 * ius: dfw.mirror.rackspace.com
 * nux-dextop: mirror.li.nux.ro
 * remi-safe: mirror.bebout.net
 * updates: repo.miserver.it.umich.edu
Resolving Dependencies
--> Running transaction check
---> Package bind-utils.x86_64 32:9.9.4-72.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package            Arch           Version                   Repository    Size
================================================================================
Installing:
 bind-utils         x86_64         32:9.9.4-72.el7           base         206 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 206 k
Installed size: 431 k
Downloading packages:
bind-utils-9.9.4-72.el7.x86_64.rpm                         | 206 kB   00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 32:bind-utils-9.9.4-72.el7.x86_64                            1/1
  Verifying  : 32:bind-utils-9.9.4-72.el7.x86_64                            1/1

Installed:
  bind-utils.x86_64 32:9.9.4-72.el7

Complete!

Done!, now you can use both dig and host command:

[root@tutorialspots ~]# host
Usage: host [-aCdlriTwv] [-c class] [-N ndots] [-t type] [-W time]
            [-R number] [-m flag] hostname [server]
       -a is equivalent to -v -t ANY
       -c specifies query class for non-IN data
       -C compares SOA records on authoritative nameservers
       -d is equivalent to -v
       -l lists all hosts in a domain, using AXFR
       -i IP6.INT reverse lookups
       -N changes the number of dots allowed before root lookup is done
       -r disables recursive processing
       -R specifies number of retries for UDP packets
       -s a SERVFAIL response should stop query
       -t specifies the query type
       -T enables TCP/IP mode
       -v enables verbose output
       -w specifies to wait forever for a reply
       -W specifies how long to wait for a reply
       -4 use IPv4 query transport only
       -6 use IPv6 query transport only
       -m set memory debugging flag (trace|record|usage)

Now you have these files:

[root@tutorialspots ~]# rpm -ql bind-utils
/etc/trusted-key.key
/usr/bin/dig
/usr/bin/host
/usr/bin/nslookup
/usr/bin/nsupdate
/usr/share/man/man1/dig.1.gz
/usr/share/man/man1/host.1.gz
/usr/share/man/man1/nslookup.1.gz
/usr/share/man/man1/nsupdate.1.gz

bind-utils

Leave a Reply