Operations 5 min read

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.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Master nslookup on Linux: Install, Commands, and Practical Tips

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 dnsutils

The 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-utils

The 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.com

Usage 2: Specify DNS server

Provide a DNS server IP after the domain to query using that server.

nslookup example.com 8.8.8.8

Usage 3: Query specific DNS record type

Use the -type=MX option to retrieve MX records.

nslookup -type=MX example.com

Usage 4: Reverse lookup

Query a domain name from an IP address.

nslookup 1.1.1.1

Usage 5: Set search domain

Use -d2 to specify a search domain.

nslookup -d2 example.com

Usage 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.com

Usage 7: Exit nslookup

In interactive mode, type exit or quit to leave.

exit

Using 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.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

linuxDNSnetwork-toolsnslookup
MaGe Linux Operations
Written by

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.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.