Operations 7 min read

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.

Lakehouse Research Base
Lakehouse Research Base
Lakehouse Research Base
nslookup Command Guide: Query DNS Records for Network Troubleshooting

Introduction

nslookup

is 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

nslookup

operates 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.com
nslookup baidu.com output showing IP address
nslookup baidu.com output showing IP address

Case 2: Query MX Record

To retrieve mail exchange servers for baidu.com:

nslookup -type=mx baidu.com
nslookup MX record output for baidu.com
nslookup MX record output for baidu.com

Case 3: Query Name Servers (NS Record)

To find the authoritative name servers for baidu.com:

nslookup -type=ns baidu.com
nslookup NS record output for baidu.com
nslookup NS record output for baidu.com

Case 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.8
nslookup reverse lookup output for 8.8.8.8
nslookup reverse lookup output for 8.8.8.8

Case 5: Enable Debug Mode

To display detailed debug information for troubleshooting complex DNS issues:

nslookup -debug baidu.com
nslookup debug output for baidu.com
nslookup debug output for baidu.com

Case 6: Query IPv6 Address (AAAA Record)

To retrieve the IPv6 address for baidu.com:

nslookup -type=AAAA baidu.com
nslookup AAAA record output for baidu.com
nslookup AAAA record output for baidu.com

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

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.

network troubleshootingcommand-lineDNSnslookupdebug modeDNS recordsinteractive modenon-interactive mode
Lakehouse Research Base
Written by

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.

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.