Home / Nslookup: command not found error on CentOS 5

Nslookup: command not found error on CentOS 5

I've just started using a VPS (Virtual Private Server) with CentOS 5.0 i386 as the virtual server operating system, but it has a pretty minimal operating system install. When I went to run the nslookup command to look up an IP address I got the error message nslookup: command not found as shown in the example below.

$ nslookup www.google.com
bash: nslookup: command not found 

So I obviously needed to install the package that contains the nslookup tool. Unfortunately doing yum search nslookup didn't produce any results. I know from using other Linux distros that nslookup is usually part of the bind tools library, so did a yum search bind and managed to find this package:

bind-utils.i386 30:9.3.3-9.0.1.el5 updates
Matched from:
bind-utils
Bind-utils contains a collection of utilities for querying DNS (Domain Name System) 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.

You should install bind-utils if you need to get information from DNS name servers.
http://www.isc.org/products/BIND/

Aha, this looked promising, so a quick yum install bind-utils should do the trick:

$ yum install bind-utils
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
base                      100% |=========================| 1.1 kB    00:00
updates                   100% |=========================|  951 B    00:00
centosplus                100% |=========================|  951 B    00:00
addons                    100% |=========================|  951 B    00:00
extras                    100% |=========================| 1.1 kB    00:00
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Package bind-utils.i386 30:9.3.3-9.0.1.el5 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 bind-utils              i386       30:9.3.3-9.0.1.el5  updates           162 k

Transaction Summary
=============================================================================
Install      1 Package(s)
Update       0 Package(s)
Remove       0 Package(s)

Total download size: 162 k
Is this ok [y/N]:

So now that bind-utils was installed, it was just a matter of running nslookup again to test and see if I actually had the tool I needed installed:

$ nslookup www.google.com
Server:         210.55.4.10
Address:        210.55.4.10#53

Non-authoritative answer:
www.google.com  canonical name = www.l.google.com.
Name:   www.l.google.com
Address: 74.125.19.104
Name:   www.l.google.com
Address: 74.125.19.147
Name:   www.l.google.com
Address: 74.125.19.99
Name:   www.l.google.com
Address: 74.125.19.103

That looks good!