Table of Contents
The nslookup command in Linux is a powerful network administration utility used to query DNS (Domain Name System) servers. It helps diagnose DNS-related issues, retrieve domain addresses, perform reverse lookups, and more. Whether you’re a sysadmin or a dev, understanding nslookup is crucial for troubleshooting and diagnostics.
What is the nslookup Command in Linux?
nslookup (short for “name server lookup”) is a command-line tool used to obtain domain name or IP address mapping. While originally from Unix systems, it is available on most platforms including Linux distributions like Debian, Ubuntu, CentOS, and Fedora.
How to Install nslookup on Linux
If the command isn’t available on your Linux system by default, especially on Debian-based distros, you’ll need to install it.
Install nslookup on Debian or Ubuntu

sudo apt update
sudo apt install dnsutils
The dnsutils
package provides nslookup along with other DNS-related tools. This process is also known as apt install nslookup in Debian environments.
Common Use Cases for the nslookup Command
Here are 7 powerful uses that demonstrate its full capabilities:
- Basic Domain Lookup
To find the IP address associated with a domain:nslookup example.com
- Query Specific DNS Records (nslookup query types)
You can specify which nslookup type of DNS record you want to retrieve:nslookup -type=MX example.com
This retrieves mail exchange records using the nslookup mx query type.
- Reverse DNS Lookup (reverse nslookup command)
To find the domain name associated with an IP:nslookup 93.184.216.34
This is often used for email servers or logging purposes.
- Query from a Specific DNS Server
Test DNS resolution from a particular provider:nslookup example.com 8.8.8.8
This queries Google’s public DNS server.
- Interactive Mode
Launch interactive mode with:nslookup
Then enter manual commands like:
set type=NS
example.com - Check Nameserver Lookup
Want to know which name servers are authoritative for your domain?nslookup -type=NS example.com
This shows all authoritative name servers.
- Troubleshoot Email Delivery (MX Records)
Mail not routing correctly? Use:nslookup -type=MX yourdomain.com
Verifying your MX records helps identify and fix potential delivery issues.
Understanding nslookup Query Types
The nslookup tool supports various query types, each retrieving different DNS records. Here’s a useful reference:
Query Type | Description | Example Command |
---|---|---|
A | Returns IPv4 address | nslookup -type=A example.com |
AAAA | Returns IPv6 address | nslookup -type=AAAA example.com |
MX | Mail exchange servers | nslookup -type=MX example.com |
NS | Authoritative name servers | nslookup -type=NS example.com |
TXT | Text records (e.g., SPF, DKIM) | nslookup -type=TXT example.com |
SOA | Start of authority record | nslookup -type=SOA example.com |
Tips & Best Practices
- For scripting or automation, redirect output to a file using
> output.txt
. - Use
dig
as an alternative for more advanced DNS queries. - Always specify type explicitly when debugging DNS records to avoid ambiguity.
Why Use nslookup Over Other Tools?
While tools like dig or host offer deeper insights, nslookup remains widely used due to its legacy support, simplicity, and integration into many automated environments. It’s especially helpful for quick lookups, educational purposes, and basic troubleshooting.
Final Thoughts
The nslookup command in Linux is essential for anyone managing networks or diagnosing domain-related issues. Whether you’re doing routine DNS checks or debugging a complex email server issue, mastering nslookup gives you a reliable first line of inspection. Once you’ve covered the basics, expand into using dig or checking your DNS from different global resolvers to ensure robustness across contexts.
FAQs About nslookup Command in Linux
- Q1: Does nslookup work on all Linux distributions?
Yes. Although it may not be preinstalled, you can use the package manager (like apt or yum) to install it easily. - Q2: Is nslookup deprecated?
No, but some experts preferdig
orhost
for more robust output. Still, nslookup remains widely used. - Q3: What’s the difference between nslookup and dig?
dig provides more detailed, script-friendly output and better customization. nslookup focuses on human-readable output for quick checks. - Q4: Can I perform a reverse DNS lookup using nslookup?
Yes. Simply enter the IP instead of the domain, and it returns the associated domain name if available. - Q5: How can I check if nslookup is installed?
Typenslookup
in your terminal. If it’s not found, runsudo apt install dnsutils
(Debian) to install it.
Related Resources:
- Learn more about basic connectivity testing: What is Ping Command
- Check out other Network Troubleshooting Commands: 10 Essential Tips for IT Professionals