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
dnsutilsorbind-utilspackage rather than a standalone package namednslookup. - 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.
- Open your terminal or SSH shell.
- Synchronise package manager indexes:
sudo apt update - Install the DNS utilities package:
Note: On newer Ubuntu releases (such as 22.04 and 24.04), you can also run:sudo apt install dnsutils -ysudo apt install bind9-dnsutils -y - 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.
- On modern RHEL 8/9, Rocky Linux, AlmaLinux, and Fedora systems, run:
sudo dnf install bind-utils -y - On legacy CentOS 7 servers, run:
sudo yum install bind-utils -y - 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.
- In Alpine Linux containers, install the
bind-toolspackage:apk add --no-cache bind-tools - On Arch Linux and Manjaro systems, execute:
sudo pacman -S bind -y - 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.
- Use
dig(Domain Information Groper), which is often pre-installed or bundled withdnsutils:dig google.com +short - On systemd-based Linux systems utilizing
systemd-resolved, query the system resolver directly:resolvectl query google.com - Use
getentto test how the operating system resolves hostnames via/etc/nsswitch.conf:getent hosts google.com