The “nslookup” is a command-line tool used for querying Domain Name System (DNS) servers to obtain information about DNS records. It is commonly used for troubleshooting network connectivity issues, as well as for verifying DNS configurations.
This guide will provide possible solutions to fix the “Nslookup: command not found” error on RHEL/CentOS.
- Reason: Not Installed “Nslookup” Command
- Solution: Install the bind-utils Package
- Check the nslookup Command Version
- Query the DNS Server
- Reason 2: Not Set the Environment Variable
- Solution: Set the Environment Variable
- Verify the Environment Variable
- Check the nslookup Version
Reason: Not Installed “Nslookup” Command
The “Nslookup: command not found” error on CentOS is an indication that the nslookup command is not installed as below:
Solution: Install the bind-utils Package
To resolve the “Nslookup: command not found” error on CentOS, users can install the bind-utils package, which includes the nslookup command. For this, use the following command:
$ yum install bind-utils
This command installs the bind-utils package and makes the nslookup command available for use.
To verify whether the error is fixed or not, use the version option with the nslookup command:
# nslookup -version
The output shows that nslookup has the “9.11.4” version in the system.
Reason 2: Not Set the Environment Variable
The “Nslookup: command not found” error on CentOS is an indication that the nslookup command is not available in the current environment.
Solution: Set the Environment Variable
To set the environment variable of NSLookup on CentOS, enter the following command to set the value of the environment variable:
# export NSLOOKUP_OPTIONS="-debug"
It sets the value of the environment variable to “-debug”. Users can replace “-debug” with any other valid option that users want to use.
Set the Environment Variable (Permanent)
To make the change permanent, you can add the export command to the .bashrc file:
# echo 'export NSLOOKUP_OPTIONS="-debug"' >> ~/.bashrc
It adds the export command to the .bashrc file, which will set the environment variable every time you open a new terminal window.
Verify the Environment Variable
To verify that the environment variable has been set correctly, enter the following command:
# echo $NSLOOKUP_OPTIONS
It displays the value that users set for the environment variable.
Check the nslookup Version:
To verify whether the error is fixed or not, use the version option with the nslookup command:
# nslookup -version
The output shows that nslookup has the “9.11.4” version in the system.
Conclusion
The “Nslookup: command not found” error occurs if the nslookup command is not installed or does not set the environment variable. To resolve the error, install the “bind-utils package” via the “yum install bind-utils” command. It installs the nslookup command which is part of the bind-utils package. After installing, users can perform DNS lookups.
This guide has covered multiple solutions to fix the “Nslookup: command not found” error on RHEL/CentOS.