How to Install Nslookup on Debian 12?


Nslookup (“Name Server Lookup”) is a command-line utility that allows users to query DNS servers. It obtains information about domain names as well as IP addresses. It is useful for troubleshooting DNS issues, finding the authoritative domain name server, performing security checks, checking the MX records of a domain, and more.

By considering its importance, this article will demonstrate different methods to install nslookup commands on Debian 12. In addition, learn how to use some basic nslookup commands and options to perform common DNS queries.

How to Install Nslookup on Debian 12?

How to Use Nslookup Command on Debian 12?

Note: Nslookup is usually installed by default on Linux distributions, such as Debian 12. However, if for some reason you need to install nslookup on the Debian 12 system, follow this guide.

How to Install Nslookup on Debian 12?

nslookup is a useful tool for querying DNS servers and resolving domain names. To install nslookup on Debian 12, use the default repositories. It is the easiest way to install nslookup on Debian 12 via the apt package manager. It automatically installs all the dependencies and configures nslookup for you.

To install nslookup from the default repositories, follow these steps:

Step 1: Update Package Lists

Before installing nslookup tool/command, update as well as upgrade the package lists with the below command:

sudo apt update && sudo apt upgrade

Step 2: Install nslookup

Now, install nslookup and its dependencies with the “dnsutils” package:

sudo apt install dnsutils

Step 3: Verify Installed nslookup

Finally, verify that nslookup is installed and its version by using the “version” option:

nslookup -version

In this way, the latest version of nslookup is installed on Debian 12.

How to Use Nslookup Command on Debian 12?

For querying DNS servers and resolving domain names to IP addresses and vice versa, users can utilize the “nslookup” command. The syntax of the “nslookup” command is given below:

 nslookup [options] [name] [server]

The description is given below:

The “options” are flags (optional) that change the command behavior, e.g. -type, -debug, -timeout, etc. The “name” is the IP address/domain name that users require to look up. The “server” is the DNS server you want to query, which defaults to your system’s configured DNS server if not specified.

Here are some common examples of using the nslookup command on Debian 12:

Example 1: Query DNS Using Domain Name

To display the IP address of a specific domain name, use the “nslookup” command followed by the domain name. For instance, use the “linuxgenie.net” as the domain name:

nslookup linuxgenie.net

It returns the IPv4 and IPv6 records for “linuxgenie.net” from your default DNS server.

Example 2: Query DNS Using IP Address

To visualize the domain name of a particular IP address, utilize nslookup followed by the IP address. It returns the PTR (pointer) record for “yahoo.com” from your default DNS server,

nslookup 74.6.231.20

Example 3: Specify a Different DNS Server

To specify a different DNS server to query, use nslookup followed by the name or IP address and then the DNS server. For instance, use “yahoo.com” as the domain name and “8.8.8.8” as the DNS server:

nslookup yahoo.com 8.8.8.8

It returns the IPv4 and IPv6 records for yahoo.com from Google’s public DNS server (8.8.8.8).

Example 4: Query a Specific Type of DNS Record

For querying a particular type of DNS record, use the “-type” option followed by the record type “mx” (mail exchange). For instance, use the “yahoo.com” for the DNS record:

nslookup -type=mx yahoo.com

It returns the MX records for “yahoo.com” from your default DNS server, which is the server that handles email delivery for that domain.

Optional: Store Record into a File

Users can also save the output to a text file such as “info.txt” for analysis via the following command:

nslookup -type=mx yahoo.com > info.txt

Example 5: Interactive Mode of nslookup Command

To enter the interactive mode of nslookup, where you can type multiple queries without exiting the command, use nslookup without any arguments. It prompts users with a > sign, where users can type any query as described above. For instance, a query for “yahoo.com” as below:

nslookup

To exit the interactive mode, type exit or press Ctrl+C.

Example 6: Sort the DNS Query (Based Server Name)

Users can sort the DNS query output based on needs. For instance, sort the query using the first column “server name”. Here, “NS” represents the name server for “yahoo.com”:

nslookup -type=NS yahoo.com | sort -k 1

These are some of the most common uses of the nslookup command on Debian 12.

Manual Page

There are many more options and features that you can explore by reading the man page via the below command:

man nslookup

Bonus Tip:

Users can utilize the “dig” and “host” commands as an alternative to get the same operations.

Conclusion

Nslookup assists users in troubleshooting network issues, verifying DNS configurations, and performing security audits. To install Nslookup on Debian 12, update your system and then, install the “dnsutils” package. Then, run nslookup from the command line or use its interactive mode. Users can also customize nslookup with various options and parameters.

This guide has discussed step-by-step procedures to install and use the nslookup command on Debian 23.

 

Categories