How to install nslookup on Ubuntu

Install nslookup on Ubuntu by installing the dnsutils package, which includes nslookup and other BIND DNS query tools.

Install nslookup on Ubuntu by installing the dnsutils package, which provides nslookup along with other BIND DNS utilities like dig and host.

Prerequisites

  • An Ubuntu system (20.04, 22.04, or 24.04).
  • A user account with sudo privileges.
  • Terminal access.

Step-by-Step: Install nslookup on Ubuntu

  1. Update the system package list to ensure the latest package versions are available:

    sudo apt update

    APT (Advanced Package Tool) downloads the current package index from the configured repositories.

    Expected output:

    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    62 packages can be upgraded. Run 'apt list --upgradable' to see them.

    nslookup installation on Ubuntu: apt update success message

  2. Install the dnsutils package, which contains nslookup and other BIND DNS query tools:

    sudo apt install dnsutils

    APT installs the bind9-dnsutils package (the current package name) along with its dependencies. The dnsutils name is a transitional package that redirects to bind9-dnsutils.

    If nslookup is already installed, APT displays a confirmation message:

    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    Note, selecting 'bind9-dnsutils' instead of 'dnsutils'
    bind9-dnsutils is already the newest version.
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

    nslookup installation on Ubuntu: dnsutils is already installed

How to Verify

Run nslookup with a test domain to confirm the installation succeeded:

nslookup example.com

nslookup should return the IP address for example.com from the system's configured DNS resolver. If the command is found and returns DNS results, the installation is complete.

Common Issues

The apt install dnsutils command returns "E: Unable to locate package dnsutils."The package repositories are not configured or the package list is outdated. Run sudo apt update first, then retry the installation.

nslookup command not found after installation.The dnsutils package installs nslookup to /usr/bin/nslookup. Verify the binary exists:

which nslookup

If the command returns no output, the package did not install correctly. Reinstall with sudo apt install --reinstall bind9-dnsutils.

nslookup is already installed but an older version.Ubuntu installs nslookup as part of the BIND 9 DNS utilities. Upgrade to the latest available version:

sudo apt update && sudo apt upgrade bind9-dnsutils