Pular para o conteúdo

Nslookup - DNS Lookup and Troubleshooting

`` ``
✅ All commands copied to clipboard!

Overview

nslookup is a network administration command-line tool for querying the Domain Name System (DNS) to obtain domain name or IP address mapping, or other DNS records. It’s available on most operating systems and is essential for DNS troubleshooting and network diagnostics.

Basic Syntax

# Non-interactive mode
nslookup [options] [name] [server]

# Interactive mode
nslookup
nslookup -
nslookup - [server]

Essential Commands

Basic DNS Lookups

# Look up A record (IPv4 address)
nslookup google.com

<button @click='copyCommand("nslookup google.com")' class="copy-btn">Copy

# Look up using specific DNS server
nslookup google.com 8.8.8.8

<button @click='copyCommand("nslookup google.com 8.8.8.8")' class="copy-btn">Copy

# Reverse DNS lookup (IP to domain)
nslookup 8.8.8.8

<button @click='copyCommand("nslookup 8.8.8.8")' class="copy-btn">Copy

Record Type Queries

# A record (IPv4 address)
nslookup -type=A google.com

<button @click='copyCommand("nslookup -type=A google.com")' class="copy-btn">Copy

# AAAA record (IPv6 address)
nslookup -type=AAAA google.com

<button @click='copyCommand("nslookup -type=AAAA google.com")' class="copy-btn">Copy

# MX record (Mail Exchange)
nslookup -type=MX google.com

<button @click='copyCommand("nslookup -type=MX google.com")' class="copy-btn">Copy

# NS record (Name Server)
nslookup -type=NS google.com

<button @click='copyCommand("nslookup -type=NS google.com")' class="copy-btn">Copy

# TXT record (Text records)
nslookup -type=TXT google.com

<button @click='copyCommand("nslookup -type=TXT google.com")' class="copy-btn">Copy

# CNAME record (Canonical Name)
nslookup -type=CNAME www.google.com

<button @click='copyCommand("nslookup -type=CNAME www.google.com")' class="copy-btn">Copy

# SOA record (Start of Authority)
nslookup -type=SOA google.com

<button @click='copyCommand("nslookup -type=SOA google.com")' class="copy-btn">Copy

# PTR record (Pointer for reverse lookup)
nslookup -type=PTR 8.8.8.8

<button @click='copyCommand("nslookup -type=PTR 8.8.8.8")' class="copy-btn">Copy

# ANY record (All available records)
nslookup -type=ANY google.com

<button @click='copyCommand("nslookup -type=ANY google.com")' class="copy-btn">Copy

# SRV record (Service record)
nslookup -type=SRV _sip._tcp.example.com

<button @click='copyCommand("nslookup -type=SRV _sip._tcp.example.com")' class="copy-btn">Copy

Interactive Mode

Starting Interactive Mode

# Enter interactive mode
nslookup

<button @click='copyCommand("nslookup")' class="copy-btn">Copy

# Enter interactive mode with specific server
nslookup - 8.8.8.8

<button @click='copyCommand("nslookup - 8.8.8.8")' class="copy-btn">Copy

Interactive Mode Commands

# Change DNS server
server 8.8.8.8

<button @click='copyCommand("server 8.8.8.8")' class="copy-btn">Copy

# Set query type to MX
set type=MX

<button @click='copyCommand("set type=MX")' class="copy-btn">Copy

# Set query type to NS
set type=NS

<button @click='copyCommand("set type=NS")' class="copy-btn">Copy

# Enable debug mode
set debug

<button @click='copyCommand("set debug")' class="copy-btn">Copy

# Disable debug mode
set nodebug

<button @click='copyCommand("set nodebug")' class="copy-btn">Copy

# Show all current settings
set all

<button @click='copyCommand("set all")' class="copy-btn">Copy

# Exit interactive mode
exit

<button @click='copyCommand("exit")' class="copy-btn">Copy

Advanced Options

Debug and Troubleshooting

# Enable debug output
nslookup -debug google.com

<button @click='copyCommand("nslookup -debug google.com")' class="copy-btn">Copy

# Specify custom port
nslookup -port=53 google.com

<button @click='copyCommand("nslookup -port=53 google.com")' class="copy-btn">Copy

# Set timeout (seconds)
nslookup -timeout=10 google.com

<button @click='copyCommand("nslookup -timeout=10 google.com")' class="copy-btn">Copy

# Set retry attempts
nslookup -retry=3 google.com

<button @click='copyCommand("nslookup -retry=3 google.com")' class="copy-btn">Copy

# Use recursive query
nslookup -recurse google.com

<button @click='copyCommand("nslookup -recurse google.com")' class="copy-btn">Copy

# Disable recursive query
nslookup -norecurse google.com

<button @click='copyCommand("nslookup -norecurse google.com")' class="copy-btn">Copy

# Use TCP instead of UDP
nslookup -vc google.com

<button @click='copyCommand("nslookup -vc google.com")' class="copy-btn">Copy

# Google DNS
nslookup google.com 8.8.8.8

<button @click='copyCommand("nslookup google.com 8.8.8.8")' class="copy-btn">Copy

# Cloudflare DNS
nslookup google.com 1.1.1.1

<button @click='copyCommand("nslookup google.com 1.1.1.1")' class="copy-btn">Copy

# OpenDNS
nslookup google.com 208.67.222.222

<button @click='copyCommand("nslookup google.com 208.67.222.222")' class="copy-btn">Copy

# Quad9 DNS
nslookup google.com 9.9.9.9

<button @click='copyCommand("nslookup google.com 9.9.9.9")' class="copy-btn">Copy

Common Use Cases

Email Server Troubleshooting

# Check MX records for email routing
nslookup -type=MX example.com

<button @click='copyCommand("nslookup -type=MX example.com")' class="copy-btn">Copy

# Verify mail server IP
nslookup mail.example.com

<button @click='copyCommand("nslookup mail.example.com")' class="copy-btn">Copy

Domain Verification

# Check domain ownership via TXT records
nslookup -type=TXT example.com

<button @click='copyCommand("nslookup -type=TXT example.com")' class="copy-btn">Copy

# Verify SPF records
nslookup -type=TXT example.com|grep "v=spf1"

<button @click='copyCommand("nslookup -type=TXT example.com|grep \"v=spf1\"")' class="copy-btn">Copy

Network Diagnostics

# Check authoritative name servers
nslookup -type=NS example.com

<button @click='copyCommand("nslookup -type=NS example.com")' class="copy-btn">Copy

# Verify reverse DNS
nslookup 192.168.1.1

<button @click='copyCommand("nslookup 192.168.1.1")' class="copy-btn">Copy

# Check domain authority info
nslookup -type=SOA example.com

<button @click='copyCommand("nslookup -type=SOA example.com")' class="copy-btn">Copy

Batch Operations

Multiple Queries

# Query multiple domains from file
nslookup -type=A ``< domains.txt

<button @click=‘copyCommand(“nslookup -type=A < domains.txt”)’ class=“copy-btn”>“Copy

# Pipe domain to nslookup
echo "google.com"|nslookup

<button @click='copyCommand("echo \"google.com\"|nslookup")' class="copy-btn">Copy

Error Messages

ErrorMeaning
** server can't find domain: NXDOMAINDomain doesn’t exist
** server can't find domain: SERVFAILDNS server failure
** server can't find domain: REFUSEDQuery refused by server
** Request timed outNo response from DNS server
** No response from serverDNS server unreachable

Installation

Linux (Ubuntu/Debian)

sudo apt-get install dnsutils

Linux (CentOS/RHEL/Fedora)

sudo yum install bind-utils
# or
sudo dnf install bind-utils

Windows

nslookup comes pre-installed with Windows.

macOS

nslookup comes pre-installed with macOS.

Tips and Best Practices

  1. Use specific DNS servers for testing to avoid cached results
  2. Enable debug mode when troubleshooting complex issues
  3. Check multiple record types for comprehensive domain analysis
  4. Use reverse lookups to verify IP address ownership
  5. Compare results from different DNS servers to identify inconsistencies
  6. Interactive mode is useful for multiple queries on the same server
  7. Combine with other tools like dig and host for complete DNS analysis
  • dig - More detailed DNS lookup tool
  • host - Simple DNS lookup utility
  • ping - Test network connectivity
  • traceroute - Trace network path
  • whois - Domain registration information