How to use command host and dig on Centos 6 and Centos 7


Command host and dig are available on Centos 5, but they are missing on Centos 6 and Centos 7. You can’t install them with yum command like

[root@tutorialspots home]# yum install dig
Loaded plugins: fastestmirror
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
base                                                     | 3.6 kB     00:00
epel/x86_64/metalink                                     | 5.7 kB     00:00
epel                                                     | 4.3 kB     00:00
extras                                                   | 3.4 kB     00:00
nginx                                                    | 2.9 kB     00:00
remi                                                     | 2.9 kB     00:00
remi-php56                                               | 2.9 kB     00:00
remi-safe                                                | 2.9 kB     00:00
updates                                                  | 3.4 kB     00:00
(1/7): extras/7/x86_64/primary_db                          | 165 kB   00:00
(2/7): epel/x86_64/updateinfo                              | 628 kB   00:00
(3/7): updates/7/x86_64/primary_db                         | 7.8 MB   00:00
(4/7): epel/x86_64/primary_db                              | 4.2 MB   00:00
(5/7): remi-php56/primary_db                               | 200 kB   00:00
(6/7): remi-safe/primary_db                                | 531 kB   00:01
(7/7): remi/primary_db                                     | 1.5 MB   00:01
Determining fastest mirrors
 * base: ftp.iij.ad.jp
 * epel: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * remi: mirrors.thzhost.com
 * remi-php56: mirrors.thzhost.com
 * remi-safe: mirrors.thzhost.com
 * updates: ftp.iij.ad.jp
No package dig available.
Error: Nothing to do

But we can use this command to install host and dig

yum install bind-utils jwhois

yum install bind utils jwhois

Result:

[root@tutorialspots home]# yum install bind-utils jwhois
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * remi: mirrors.thzhost.com
 * remi-php56: mirrors.thzhost.com
 * remi-safe: mirrors.thzhost.com
 * updates: ftp.iij.ad.jp
Resolving Dependencies
--> Running transaction check
---> Package bind-utils.x86_64 32:9.9.4-29.el7_2.4 will be installed
--> Processing Dependency: bind-libs = 32:9.9.4-29.el7_2.4 for package: 32:bind-
utils-9.9.4-29.el7_2.4.x86_64
--> Processing Dependency: liblwres.so.90()(64bit) for package: 32:bind-utils-9.
9.4-29.el7_2.4.x86_64
--> Processing Dependency: libisccfg.so.90()(64bit) for package: 32:bind-utils-9
.9.4-29.el7_2.4.x86_64
--> Processing Dependency: libisccc.so.90()(64bit) for package: 32:bind-utils-9.
9.4-29.el7_2.4.x86_64
--> Processing Dependency: libisc.so.95()(64bit) for package: 32:bind-utils-9.9.
4-29.el7_2.4.x86_64
--> Processing Dependency: libdns.so.100()(64bit) for package: 32:bind-utils-9.9
.4-29.el7_2.4.x86_64
--> Processing Dependency: libbind9.so.90()(64bit) for package: 32:bind-utils-9.
9.4-29.el7_2.4.x86_64
---> Package jwhois.x86_64 0:4.0-45.el7 will be installed
--> Processing Dependency: libidn2.so.0(IDN2_0.0.0)(64bit) for package: jwhois-4
.0-45.el7.x86_64
--> Processing Dependency: libidn2.so.0()(64bit) for package: jwhois-4.0-45.el7.
x86_64
--> Running transaction check
---> Package bind-libs.x86_64 32:9.9.4-29.el7_2.4 will be installed
--> Processing Dependency: bind-license = 32:9.9.4-29.el7_2.4 for package: 32:bi
nd-libs-9.9.4-29.el7_2.4.x86_64
---> Package libidn2.x86_64 0:0.10-2.el7 will be installed
--> Running transaction check
---> Package bind-license.noarch 32:9.9.4-29.el7_2.3 will be updated
--> Processing Dependency: bind-license = 32:9.9.4-29.el7_2.3 for package: 32:bi
nd-libs-lite-9.9.4-29.el7_2.3.x86_64
---> Package bind-license.noarch 32:9.9.4-29.el7_2.4 will be an update
--> Running transaction check
---> Package bind-libs-lite.x86_64 32:9.9.4-29.el7_2.3 will be updated
---> Package bind-libs-lite.x86_64 32:9.9.4-29.el7_2.4 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package             Arch        Version                     Repository    Size
================================================================================
Installing:
 bind-utils          x86_64      32:9.9.4-29.el7_2.4         updates      200 k
 jwhois              x86_64      4.0-45.el7                  epel         116 k
Installing for dependencies:
 bind-libs           x86_64      32:9.9.4-29.el7_2.4         updates      1.0 M
 libidn2             x86_64      0.10-2.el7                  epel          96 k
Updating for dependencies:
 bind-libs-lite      x86_64      32:9.9.4-29.el7_2.4         updates      724 k
 bind-license        noarch      32:9.9.4-29.el7_2.4         updates       82 k

Transaction Summary
================================================================================
Install  2 Packages (+2 Dependent packages)
Upgrade             ( 2 Dependent packages)

Total download size: 2.2 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/6): bind-license-9.9.4-29.el7_2.4.noarch.rpm            |  82 kB   00:00
(2/6): bind-libs-9.9.4-29.el7_2.4.x86_64.rpm               | 1.0 MB   00:00
(3/6): jwhois-4.0-45.el7.x86_64.rpm                        | 116 kB   00:00
(4/6): bind-utils-9.9.4-29.el7_2.4.x86_64.rpm              | 200 kB   00:00
(5/6): bind-libs-lite-9.9.4-29.el7_2.4.x86_64.rpm          | 724 kB   00:00
(6/6): libidn2-0.10-2.el7.x86_64.rpm                       |  96 kB   00:00
--------------------------------------------------------------------------------
Total                                              6.5 MB/s | 2.2 MB  00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : 32:bind-license-9.9.4-29.el7_2.4.noarch                      1/8
  Installing : 32:bind-libs-9.9.4-29.el7_2.4.x86_64                         2/8
  Installing : libidn2-0.10-2.el7.x86_64                                    3/8
  Installing : jwhois-4.0-45.el7.x86_64                                     4/8
  Installing : 32:bind-utils-9.9.4-29.el7_2.4.x86_64                        5/8
  Updating   : 32:bind-libs-lite-9.9.4-29.el7_2.4.x86_64                    6/8
  Cleanup    : 32:bind-libs-lite-9.9.4-29.el7_2.3.x86_64                    7/8
  Cleanup    : 32:bind-license-9.9.4-29.el7_2.3.noarch                      8/8
  Verifying  : 32:bind-license-9.9.4-29.el7_2.4.noarch                      1/8
  Verifying  : libidn2-0.10-2.el7.x86_64                                    2/8
  Verifying  : jwhois-4.0-45.el7.x86_64                                     3/8
  Verifying  : 32:bind-libs-lite-9.9.4-29.el7_2.4.x86_64                    4/8
  Verifying  : 32:bind-utils-9.9.4-29.el7_2.4.x86_64                        5/8
  Verifying  : 32:bind-libs-9.9.4-29.el7_2.4.x86_64                         6/8
  Verifying  : 32:bind-license-9.9.4-29.el7_2.3.noarch                      7/8
  Verifying  : 32:bind-libs-lite-9.9.4-29.el7_2.3.x86_64                    8/8

Installed:
  bind-utils.x86_64 32:9.9.4-29.el7_2.4        jwhois.x86_64 0:4.0-45.el7

Dependency Installed:
  bind-libs.x86_64 32:9.9.4-29.el7_2.4        libidn2.x86_64 0:0.10-2.el7

Dependency Updated:
  bind-libs-lite.x86_64 32:9.9.4-29.el7_2.4
  bind-license.noarch 32:9.9.4-29.el7_2.4

Complete!

Now, you can use two commands host and dig

use host and dig

[root@tutorialspots home]# 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)
[root@tutorialspots home]# dig

; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7_2.4 <<>>
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 11792
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 13, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;.                              IN      NS

;; ANSWER SECTION:
.                       435881  IN      NS      k.root-servers.net.
.                       435881  IN      NS      d.root-servers.net.
.                       435881  IN      NS      h.root-servers.net.
.                       435881  IN      NS      l.root-servers.net.
.                       435881  IN      NS      c.root-servers.net.
.                       435881  IN      NS      f.root-servers.net.
.                       435881  IN      NS      a.root-servers.net.
.                       435881  IN      NS      b.root-servers.net.
.                       435881  IN      NS      g.root-servers.net.
.                       435881  IN      NS      m.root-servers.net.
.                       435881  IN      NS      j.root-servers.net.
.                       435881  IN      NS      e.root-servers.net.
.                       435881  IN      NS      i.root-servers.net.

;; Query time: 1 msec
;; SERVER: 108.61.10.10#53(108.61.10.10)
;; WHEN: Sat Oct 01 16:59:48 ICT 2016
;; MSG SIZE  rcvd: 239

Leave a Reply