nslookup Command Guide: Query DNS Records for Network Troubleshooting
This guide explains the nslookup command-line tool for querying DNS records, covering interactive and non-interactive modes, supported record types (A, AAAA, MX, NS, PTR, etc.), and practical examples for domain lookup, reverse DNS, and debug mode.
Introduction
nslookupis a command-line tool used to query Domain Name System (DNS) records. It helps users diagnose DNS infrastructure problems such as checking a domain's IP address mapping, mail server settings, alias records, and more. The tool is commonly used by network administrators and technical support staff to resolve network connectivity issues.
Basic Usage
The basic syntax of the nslookup command is:
nslookup [-option] [name | -] [server]Advanced Usage: Query Types
Beyond simple lookups, nslookup supports querying specific DNS record types using the -type= (or -ty=) option. The syntax is: nslookup -type=type domain The following record types are supported:
A – Address record (default)
AAAA – IPv6 address record
AFSDB – Andrew File System database server record
ATMA – ATM address record
CNAME – Canonical name (alias) record
HINFO – Hardware information record (CPU, OS)
ISDN – ISDN number for the domain
MB – Mailbox server record
MG – Mail group record
MINFO – Mailbox and mail group information record
MR – Renamed mailbox record
MX – Mail exchange record
NS – Name server record
PTR – Pointer (reverse) record
RP – Responsible person record
RT – Route-through record
SRV – Service location record
TXT – Text record
X25 – X.25 address record
Working Modes
nslookupoperates in two modes:
Interactive mode : Entered by running nslookup -. Allows setting options, variables, and executing multiple queries in a session.
Non-interactive mode : Direct command-line query, e.g., nslookup domain [dns-server]. Suitable for one-off lookups.
Practical Examples
Case 1: Query A Record for a Domain
To get the IPv4 address of baidu.com using the system default DNS server (e.g., 8.8.8.8):
nslookup baidu.comCase 2: Query MX Record
To retrieve mail exchange servers for baidu.com:
nslookup -type=mx baidu.comCase 3: Query Name Servers (NS Record)
To find the authoritative name servers for baidu.com:
nslookup -type=ns baidu.comCase 4: Reverse DNS Lookup (PTR Record)
To resolve a domain name from an IP address (e.g., 8.8.8.8):
nslookup -q=ptr 8.8.8.8Case 5: Enable Debug Mode
To display detailed debug information for troubleshooting complex DNS issues:
nslookup -debug baidu.comCase 6: Query IPv6 Address (AAAA Record)
To retrieve the IPv6 address for baidu.com:
nslookup -type=AAAA baidu.comThese examples demonstrate the versatility of nslookup for tasks ranging from simple domain resolution to detailed DNS record inspection, making it an essential tool for network fault diagnosis and DNS investigations.
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.
Lakehouse Research Base
Focused on technical sharing in the data field, covering a tech stack that includes Hadoop, Spark, Flink, Kafka, Fluss, Paimon, Iceberg, StarRocks, ClickHouse, ES, Milvus, and more. Welcome to follow.
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.
