nslookup (Name Server Lookup) is a cross-platform DNS query tool built into Linux, macOS, and Windows. It's the go-to option when dig isn't available — letting you look up any DNS record type and query any DNS server directly.

A · MX · CNAME · TXT · NS · PTR · Interactive Mode
01 — How It Works

nslookup asks a DNS resolver to translate a name into records (or vice-versa for reverse lookups). It can run in non-interactive mode (single command) or interactive mode (a shell-like prompt for multiple queries).

nslookup works on every platform without installing anything extra — making it the universal DNS troubleshooting tool.

Unlike dig, nslookup uses its own resolver stack rather than the system's, which can occasionally produce different results. For authoritative queries, always test against a known-good server like 8.8.8.8 or 1.1.1.1.

02 — Basic Usage
Simple A record lookup
nslookup google.com
Typical output
Server: 8.8.8.8 Address: 8.8.8.8#53 Non-authoritative answer: Name: google.com Address: 142.250.185.46
FieldMeaning
ServerThe DNS server that was queried
AddressIP and port of the DNS server (port 53 = DNS)
Non-authoritativeAnswer came from a cache, not the domain's own nameserver
Name / AddressThe resolved hostname and IP address
03 — Common Queries
Query a specific DNS server
nslookup google.com 1.1.1.1
Look up a specific record type
nslookup -type=MX gmail.com nslookup -type=TXT google.com nslookup -type=NS google.com nslookup -type=AAAA google.com nslookup -type=CNAME www.github.com
Reverse lookup — IP to hostname
nslookup 8.8.8.8
Check SOA record
nslookup -type=SOA google.com
04 — Interactive Mode

Launch nslookup without arguments to enter interactive mode — useful for running multiple queries without retyping the tool name each time.

nslookup > server 8.8.8.8 # switch to a specific resolver > set type=MX # change record type > gmail.com # run the query > set type=A > google.com > exit
Interactive commandWhat it does
server <ip>Switch to querying a different DNS server
set type=<type>Change the record type (A, MX, TXT, NS, CNAME…)
set debugShow full DNS packet details
set nodebugTurn off debug output
set timeout=<n>Set query timeout in seconds
exitLeave interactive mode
05 — nslookup vs dig
nslookupdig
AvailabilityBuilt into Linux, macOS, WindowsLinux, macOS (install on Windows)
OutputSimplified, human-readableFull raw DNS response
ScriptingLimited — output harder to parseExcellent with +short, +noall
Interactive modeYesNo
DNSSECBasic supportFull support with +dnssec
Best forQuick checks, Windows environmentsDeep DNS debugging, scripting
ℹ  For quick checks on any platform, nslookup is fine. For serious DNS debugging or scripting, prefer dig.
06 — Troubleshooting
ProblemCommandWhat to check
Domain not resolvingnslookup domain.com 8.8.8.8If 8.8.8.8 works but default fails, your local resolver is the problem
Wrong IP returnednslookup domain.com 1.1.1.1Compare with your default resolver — stale cache or hijacked DNS
Email issuesnslookup -type=MX domain.comVerify MX records and their priority
SSL / certificate mismatchnslookup -type=CNAME domain.comCheck if CNAME points to the expected CDN or load balancer
NXDOMAIN errornslookup -type=NS domain.comConfirm NS records exist — domain may not be delegated
⚠  Non-authoritative answer in the output means the reply came from a resolver cache. To get the authoritative answer, query the domain's own nameserver directly: nslookup domain.com <nameserver>

nslookup DNS Query Reference linux · macos · windows