How to Fix the “nslookup command not found” Error on Linux and Windows

Nslookup is a useful command line tool for troubleshooting DNS issues and querying DNS records on Linux, Windows, and macOS systems. However, you may encounter the “nslookup command not found” error when trying to run nslookup on your system.

In this comprehensive guide, we’ll cover the reasons for the nslookup not found error and how to fix it on both Linux and Windows machines. We’ll also provide nslookup usage examples so you can quickly resolve DNS issues.

What is nslookup?

Nslookup is a command-line administrative tool for testing and troubleshooting DNS servers and name resolutions. It allows you to:

  • Query the IP address for a hostname.
  • Find the hostname for an IP address.
  • View DNS records like MX, CNAME, TXT, etc.
  • Test if a DNS server is reachable.
  • Diagnose DNS problems and errors.

The nslookup command line tool is included with most operating systems like Windows, Linux, and macOS. It provides an interactive mode where you can query DNS details or run single queries.

Here are some common examples of using nslookup:

nslookup # Query IP for hostname
nslookup # Reverse lookup hostname for IP 
nslookup -type=MX # Check mail records

Now let’s look at why you might get the “nslookup command not found” error when trying to use this handy DNS tool.

Why nslookup Is Not Found on Your System

There are a few possible reasons you may get a “nslookup command not found” error:

1. nslookup is not installed

This is the most common reason. Nslookup may not be installed on your Linux or Windows system by default.

On Linux, it’s usually included in the bind-utils package. On Windows, it’s a feature that needs to be enabled.

2. nslookup is not in your system PATH

Even if nslookup is installed, your system’s PATH environment variable may not contain the directory where nslookup is installed. So when you run it, the shell can’t locate the executable.

3. You have a typing error in the command

Double-check that you have typed nslookup correctly and not misspelled it.

4. You’re using an older version of nslookup

Some older Linux/UNIX systems included a very outdated version of nslookup in the bind-utils package that had limited functionality. Trying to run commands that don’t work in the old version will show “command not found.”

Now let’s look at how to install nslookup and add it to your system PATH to resolve the “command not found” issue.

How to Fix nslookup Command Not Found on Linux

Here are the steps to fix the nslookup not found error on a Linux system:

Step 1 – Install bind-utils Package

The nslookup executable is included in the bind-utils package on most Linux distributions. To install it:

On Debian/Ubuntu:

sudo apt update
sudo apt install bind-utils


sudo yum update
sudo yum install bind-utils

On Fedora:

sudo dnf update 
sudo dnf install bind-utils

This will install nslookup along with other handy DNS tools like dig, host, etc.

Step 2 – Add bind-utils Path to $PATH Variable

Just installing the bind-utils package may not be enough, as your system’s $PATH variable may not contain the path to the nslookup executable.

You can find where nslookup is installed by running:

which nslookup

This will typically output /usr/bin/nslookup.

To add this path, edit your shell profile script:

For Bash shells:

nano ~/.bash_profile

For Zsh shells:

nano ~/.zshrc

Then add this line to append the bind-utils path to $PATH:

export PATH=$PATH:/usr/bin

Save and close the file, then reload it:

source ~/.bash_profile
# OR
source ~/.zshrc

The nslookup command should now work when you run it again!

Step 3 – Use absolute Path to nslookup

If adding the path to your $PATH did not work, you can also run nslookup using its full absolute path:


This bypasses any $PATH issues and runs the nslookup executable directly.

And that’s it! The nslookup not found error on Linux should now be resolved.

How to Fix nslookup Not Found on Windows

On Windows machines, nslookup must be enabled as it is not included by default. Here’s how to install and enable it:

Step 1 – Install DNS Server Role

Nslookup is installed as part of the DNS Server server role in Windows. To add this role:

  1. Open Server Manager
  2. Click Manage and Add Roles and Features
  3. Select Role-based or feature-based installation
  4. On the Server Roles screen, check the box for DNS Server
  5. Click Next and Install to finish adding this role

This will install all the DNS Server features, including nslookup.

Step 2 – Add DNS Server Tools to Path

Even after installing the DNS role, you still need to add the DNS tools path to your system PATH environment variable.

The DNS tools including nslookup are located in the C:\Windows\System32\dns folder.

To add this:

  1. Open Advanced system settings
  2. Click Environment Variables
  3. Under System Variables, find the PATH variable and click Edit
  4. Click New and add C:\Windows\System32\dns
  5. Click OK to close and save this change

Now nslookup and other DNS tools will be accessible from any command prompt.

Step 3 – Restart the Command Prompt

For the new PATH changes to take effect, close any open command prompt windows and open a new one.

You should now be able to run nslookup commands successfully!


And that covers how to fix the nslookup not found error on both Linux and Windows!

Nslookup Usage and Commands

Now that you’ve installed nslookup, let’s look at some examples of how to use it to query DNS records and troubleshoot problems.

Nslookup has two modes – interactive and non-interactive.

Interactive Mode Usage

Interactive mode allows you to run multiple lookups and change settings. To use it:

# Linux/MacOS

# Windows 
nslookup -mode=interactive

This will open the > prompt where you can run commands:

> server # Change to Google DNS
> # Lookup IP address
> set type=MX # Switch to MX record lookup
> # Get MX records
> exit # Exit nslookup

Some common interactive commands:

  • server – Change the DNS server to query
  • set type=X – Sets record type X to lookup (A, AAAA, MX, TXT, etc)
  • ls – Lists all data from the DNS server
  • help – Print help info
  • exit – Exit nslookup interactive mode

Non-Interactive Mode Usage

Non-interactive mode runs a single query and then exits. Use it like:

# Linux/macOS
nslookup -type=MX 

# Windows
nslookup -query=MX

Non-interactive is useful for quick one-off lookups in scripts or via SSH.

Now let’s look at some examples of how to use nslookup commands to troubleshoot and diagnose different DNS issues.

Nslookup Troubleshooting Examples

Check the DNS IP Address

Use nslookup to check if a DNS server IP is reachable:

> server
Default server:

If the IP address is not reachable, you will get an error like “connection timed out.”

Lookup the IP for a Domain

Find the IP address mapped to a domain/hostname:


Non-authoritative answer:

If the IP returned is not what you expect, there may be a DNS resolution issue for that domain.

Reverse Lookup a Hostname

Do a reverse DNS lookup to find the hostname for an IP address:


Non-authoritative answer:     name =

If this shows the wrong hostname, the reverse DNS record (PTR) needs to be updated.

Lookup DNS Record Types

Query other DNS record types like MX, CNAME, TXT, etc:

# MX record 
nslookup -type=MX 

# CNAME record
nslookup -type=CNAME

# TXT record 
nslookup -type=TXT

This can help identify issues with mail routing, aliases, or SPF/DKIM text records.

Trace DNS Delegation and Authority

View the full chain of DNS delegation for a domain:

nslookup -type=NS

This shows the DNS servers that are authoritative for this domain at each level. Useful for troubleshooting delegation issues.

Diagnose Connectivity Issues

If your public DNS queries fail but private IPs work, it indicates a general connectivity issue:

;; connection timed out


Check your network, firewall, VPN, or proxy settings to allow public DNS resolution.

Nslookup is a powerful tool for investigating DNS problems. Use these examples and commands to quickly diagnose DNS issues on your network.

Alternative DNS Troubleshooting Tools

There are a few alternatives if nslookup is not available on your system:

  • dig – Included with Linux bind utils, offers similar DNS lookup capabilities.
  • host – Simple DNS lookup tool on Linux and Windows.
  • Resolve-DnsName – PowerShell cmdlet on Windows.
  • drill – Advanced DNS analysis tool with a focus on security evaluations.

However, nslookup remains one of the most common and convenient DNS troubleshooting tools on Windows and Linux systems. Now you know how to fix any issues getting it running on your machine.


Nslookup is an essential DNS debugging tool for network admins to have in their toolkits. If you get a “nslookup command not found” error, this is likely because it is not installed or in your system’s PATH.

On Linux, install the bind-utils package and add the path to your $PATH variable. On Windows, enable the DNS Server role and add the tools path to your system PATH.

Once available, nslookup can query DNS records, check connectivity, trace delegation chains, and more. Use it to quickly troubleshoot any DNS issues you encounter!

Leave a Comment