How to Fix nslookup Command Not Found in Linux

The nslookup (Name Server Lookup) command-line utility is a standard tool used by network engineers and system administrators to query Domain Name System (DNS) servers, verify A/AAAA records, and diagnose name resolution issues. However, when executing DNS diagnostics inside minimal Linux cloud images, Docker containers, or minimal server installations, administrators frequently encounter the error: bash: nslookup: command not found.

Why Is nslookup Missing from Minimal Linux Systems?

The nslookup binary is not part of core GNU coreutils; instead, it belongs to the BIND DNS utility suite. Minimal installations frequently omit the package to save disk space and reduce maintenance overhead. Common causes include:

  • Minimal Base Container Images: Official Docker images for Ubuntu, Debian, CentOS, and Alpine strip out DNS diagnostic utilities.
  • Package Name Ambiguity: The binary is provided by the dnsutils or bind-utils package rather than a standalone package named nslookup.
  • Unindexed Package Repositories: Fresh cloud instances lacking updated package manager repository caches.

Method 1: Install nslookup on Ubuntu and Debian Distributions

On Debian-derived distributions, nslookup is packaged inside the dnsutils (or bind9-dnsutils) meta-package.

  1. Open your terminal or SSH shell.
  2. Synchronise package manager indexes:
    sudo apt update
  3. Install the DNS utilities package:
    sudo apt install dnsutils -y
    Note: On newer Ubuntu releases (such as 22.04 and 24.04), you can also run: sudo apt install bind9-dnsutils -y
  4. Verify that nslookup is installed:
    nslookup google.com

Method 2: Install nslookup on RHEL, CentOS, Rocky Linux, and Fedora

Enterprise Linux operating systems distribute nslookup via the bind-utils package.

  1. On modern RHEL 8/9, Rocky Linux, AlmaLinux, and Fedora systems, run:
    sudo dnf install bind-utils -y
  2. On legacy CentOS 7 servers, run:
    sudo yum install bind-utils -y
  3. Verify installation by performing a reverse DNS lookup:
    nslookup 8.8.8.8

Method 3: Install nslookup on Alpine Linux and Arch Linux

Lightweight containers and rolling distributions use their own package repositories.

  1. In Alpine Linux containers, install the bind-tools package:
    apk add --no-cache bind-tools
  2. On Arch Linux and Manjaro systems, execute:
    sudo pacman -S bind -y
  3. Confirm that the binary is available:
    which nslookup

Method 4: Use Modern DNS Alternatives (dig and resolvectl)

Modern Linux systems frequently provide more powerful, modern DNS lookup utilities out of the box.

  1. Use dig (Domain Information Groper), which is often pre-installed or bundled with dnsutils:
    dig google.com +short
  2. On systemd-based Linux systems utilizing systemd-resolved, query the system resolver directly:
    resolvectl query google.com
  3. Use getent to test how the operating system resolves hostnames via /etc/nsswitch.conf:
    getent hosts google.com

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.