Master nslookup on Linux: Install and 7 Essential Commands
This guide shows how to install the nslookup tool on Debian/Ubuntu and CentOS/RHEL systems and provides seven practical usage examples, including querying IP addresses, specifying DNS servers, retrieving specific record types, performing reverse lookups, setting search domains, using the set command, and exiting the interactive mode.
Installation on Debian/Ubuntu
Use the apt package manager to install the dnsutils package, which provides the nslookup command.
sudo apt update
sudo apt install dnsutilsInstallation on CentOS/RHEL
Use yum or dnf to install the bind-utils package, which includes nslookup. Choose the command that matches your system version.
# For yum‑based systems
sudo yum install bind-utils
# For dnf‑based systems
sudo dnf install bind-utilsUsage 1: Query an IP address
Run nslookup followed by a domain name to retrieve its IPv4 address.
nslookup example.comUsage 2: Specify a DNS server
You can direct the query to a particular DNS server instead of the default local resolver.
nslookup example.com 8.8.8.8Usage 3: Query a specific DNS record type
Use the -type option to request records other than the default A record, such as MX (mail exchange) records.
nslookup -type=MX example.comUsage 4: Perform a reverse lookup
Provide an IP address to retrieve the associated domain name.
nslookup 1.1.1.1Usage 5: Set a search domain
When querying, you can define a search domain to automatically append to unqualified hostnames.
nslookup -d2 example.comUsage 6: Use the set command
Inside the interactive nslookup prompt, the set command lets you modify options such as query type or timeout.
nslookup
set type=A
example.comUsage 7: Exit the interactive mode
In interactive mode, type exit or quit to leave nslookup.
exitThe nslookup tool is useful for diagnosing DNS problems such as failed name resolution, stale caches, or misconfigurations, but keep in mind that results may be affected by local DNS cache settings or the configuration of the queried DNS server.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
