nslookup: command not found

A tool for gathering name resolution information and testing name resolution. It is available on most Linux distributions as well as Microsoft Windows. This command has a non-interactive mode, in which you can provide a domain name in a single command, and an interactive mode, in which you can issue the command by itself and then provide domain names on separate consecutive prompts.

Syntax

The syntax for non-interactive mode is:

# nslookup {domain name}

If you encounter the below error while running the nslookup command:

nslookup: command not found

you may try installing the below package as per your choice of distribution:

OS Distribution Command
Debian apt-get install dnsutils
Ubuntu apt-get install dnsutils
Alpine apk add bind-tools
Arch Linux pacman -S bind-tools
Kali Linux apt-get install dnsutils
Fedora dnf install bind-utils
Raspbian apt-get install dnsutils

nslookup Command Examples

1. The usage of nslookup command to find the IP address of domain name is shown here::

# nslookup example.com

2. The usage of nslookup command to find the authoritative nameserver of a domain is shown here:

# nslookup -type=NS example.com 8.8.8.8

3. Query for a reverse lookup (PTR record) of an IP address:

# nslookup -type=PTR 54.240.162.118

4. Query for ANY available records using TCP protocol:

# nslookup -vc -type=ANY example.com

5. Query a given name server for the whole zone file (zone transfer) of the domain using TCP protocol:

# nslookup -vc -type=AXFR example.com name_server

6. Query for a mail server (MX record) of the domain, showing details of the transaction:

# nslookup -type=MX -debug example.com

7. Query a given name server on a specific port number for a TXT record of the domain:

# nslookup -port=port_number -type=TXT example.com name_server

8. The nslookup command can be used to make a non-authoritative query of an MX record from a DNS server specified in /etc/resolv.conf file is shown here:

# nslookup -query=mx example.com

9. The nslookup command can be used to make an authoritative query of an MX record from the DNS server. We can specify the authoritative nameserver for the zone as an argument as shown here:

# nslookup -query=mx example.com ns1.example.com
Related Post