Master nslookup on Linux: Install, Commands, and Practical Tips
This guide explains how to install the nslookup tool on various Linux distributions and demonstrates seven common usages—including querying IP addresses, specifying DNS servers, retrieving specific record types, performing reverse lookups, setting search domains, using interactive set commands, and exiting the tool—to help diagnose DNS issues effectively.
nslookup is a network diagnostic tool used to query DNS records, resolve domain names to IP addresses, and retrieve other record types such as MX or CNAME.
Debian/Ubuntu and derivatives installation
Install via apt:
sudo apt update
sudo apt install dnsutilsThe dnsutils package provides the nslookup command.
CentOS/RHEL and derivatives installation
Install via yum or dnf depending on version:
# For yum-based systems
sudo yum install bind-utils
# Or for dnf-based systems
sudo dnf install bind-utilsThe bind-utils package contains the nslookup command.
Usage 1: Query IP address
Run nslookup followed by a domain name to obtain its IP address.
nslookup example.comUsage 2: Specify DNS server
Provide a DNS server IP after the domain to query using that server.
nslookup example.com 8.8.8.8Usage 3: Query specific DNS record type
Use the -type=MX option to retrieve MX records.
nslookup -type=MX example.comUsage 4: Reverse lookup
Query a domain name from an IP address.
nslookup 1.1.1.1Usage 5: Set search domain
Use -d2 to specify a search domain.
nslookup -d2 example.comUsage 6: Interactive mode with set command
Enter interactive mode by typing nslookup, then use set to change options such as query type.
nslookup
set type=A
example.comUsage 7: Exit nslookup
In interactive mode, type exit or quit to leave.
exitUsing nslookup helps diagnose DNS problems such as resolution failures, cache issues, or misconfigurations, though results may be influenced by local DNS cache or server settings.
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.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
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.
