nslookup Command Examples: 15 Real-World DNS Queries
Master nslookup with 15 real examples covering A, AAAA, MX, TXT, CNAME, NS, SOA and reverse lookups on Windows, macOS and Linux.

nslookup Command Examples: 15 Real-World DNS Queries
If you build websites, run mail servers, or troubleshoot DNS, nslookup is the fastest tool for a quick answer. This guide walks through 15 real-world queries you'll actually use — no fluff, just commands and what the output means.
Table of Contents
- What nslookup is
- Basic syntax
- Example 1 — A record
- Example 2 — AAAA (IPv6)
- Example 3 — MX record
- Example 4 — TXT record
- Example 5 — CNAME
- Example 6 — NS (name servers)
- Example 7 — SOA
- Example 8 — Reverse DNS (PTR)
- Example 9 — Query a specific DNS server
- Example 10 — Interactive mode
- Example 11 — Set timeout and retries
- Example 12 — Query via TCP instead of UDP
- Example 13 — Debug mode
- Example 14 — Non-authoritative vs authoritative
- Example 15 — Batch queries with a script
- Common mistakes and troubleshooting
- FAQ

What nslookup Is
nslookup ('name server lookup') is a command-line utility that queries DNS servers directly. It's built into Windows, macOS and Linux. Every network engineer, sysadmin, and web developer needs it in their muscle memory.
Basic Syntax
nslookup [option] name [server]. If you don't specify a server, nslookup uses whatever DNS your OS is configured to use.
Example 1 — A Record
nslookup digimetricshub.com — returns the IPv4 address(es) mapped to the domain. This is the default record type.
Example 2 — AAAA (IPv6)
nslookup -type=AAAA cloudflare.com — returns the IPv6 address(es). Modern sites publish both A and AAAA.
Example 3 — MX Record
nslookup -type=MX gmail.com — returns the mail exchanger hosts and their priority values. Lower priority number = higher preference.
Not sure which mail server your domain uses? Check with our WHOIS Lookup.
Open WHOIS LookupExample 4 — TXT Record
nslookup -type=TXT google.com — returns text records including SPF, DKIM, DMARC, and domain-verification strings for Google, Facebook, Microsoft 365 and so on.
Example 5 — CNAME
nslookup -type=CNAME www.github.com — CNAME (canonical name) points one name at another. Useful for verifying that www.example.com correctly forwards to example.com or a CDN.
Example 6 — NS (Name Servers)
nslookup -type=NS wikipedia.org — lists the authoritative name servers for the zone. If you changed hosts, this confirms whether the new NS records have propagated.
Example 7 — SOA
nslookup -type=SOA digimetricshub.com — returns the Start of Authority record with the primary NS, responsible email, and the zone's serial number. When the serial number changes, secondaries know to pull an update.
Example 8 — Reverse DNS (PTR)
nslookup 8.8.8.8 — nslookup detects that you passed an IP and automatically queries the reverse zone (in-addr.arpa) for a PTR record. Result: dns.google. See our dedicated guide for the full story.
Example 9 — Query a Specific DNS Server
nslookup digimetricshub.com 1.1.1.1 — forces the query at Cloudflare's public resolver, bypassing your OS setting. Great for testing whether an issue is your resolver or the actual record.
Example 10 — Interactive Mode
Just run nslookup with no arguments. You get a > prompt where you can type commands like set type=MX, then a domain, then another. Type exit to leave.
Example 11 — Set Timeout and Retries
nslookup -timeout=5 -retry=2 digimetricshub.com — useful on flaky links where the default single-try timeout produces false NXDOMAIN answers.
Example 12 — Query via TCP Instead of UDP
nslookup -vc digimetricshub.com forces TCP. Useful when large DNSSEC-signed answers get truncated over UDP.
Example 13 — Debug Mode
nslookup -debug digimetricshub.com prints the raw DNS packets, showing you the query flags, opcode and answer sections. Educational for anyone learning DNS internals.
Example 14 — Non-authoritative vs Authoritative
If the output starts with 'Non-authoritative answer:' the resolver served it from cache. To force an authoritative answer, query the name server directly: nslookup digimetricshub.com ns1.example.com.
Example 15 — Batch Queries with a Script
On Linux/macOS: for d in google.com bing.com duckduckgo.com; do nslookup -type=MX $d; done — runs the same query type against multiple domains. On Windows, use a .bat file with FOR loops.
Common Mistakes
- Forgetting -type= and getting the default A record when you wanted MX or TXT.
- Trusting a 'Non-authoritative' answer during migrations — always query the authoritative NS.
- Assuming ANY-type queries still work — many resolvers refuse them per RFC 8482.
- Running nslookup from behind a corporate proxy that intercepts DNS.
- Reading 'server can't find' as 'site is down' when it usually means wrong record type.
Troubleshooting
- If every query fails: your resolver is unreachable. Try nslookup digimetricshub.com 1.1.1.1.
- If one specific domain fails: check DNS Lookup online to confirm the record exists.
- If MX/TXT looks wrong after a change: DNS is cached — wait for TTL or flush your resolver.
- If you get ADDITIONAL SECTION but no ANSWER: try TCP with -vc.
Security Best Practices
- Don't rely solely on nslookup for security-sensitive checks — combine with dig +dnssec and a DNS Lookup tool.
- Query multiple public resolvers (1.1.1.1, 8.8.8.8, 9.9.9.9) to detect DNS hijacking on your network.
- Prefer DoH/DoT resolvers in production so answers can't be tampered with in transit.
Run instant DNS queries from your browser — no terminal needed.
Open DNS LookupFrequently Asked Questions
Is nslookup deprecated?+
It's older and less feature-rich than dig, but Microsoft still ships and maintains it in Windows 11. It is not deprecated, just less powerful.
What's the difference between authoritative and non-authoritative answers?+
'Non-authoritative' means the answer came from your resolver's cache. 'Authoritative' means the reply came directly from the domain's own DNS server. Both are valid; authoritative is fresher.
How do I query a specific DNS server?+
Add the server after the domain: nslookup digimetricshub.com 1.1.1.1 asks Cloudflare's resolver instead of your default.
Why does nslookup on Windows show 'server can't find'?+
Either the record doesn't exist (NXDOMAIN), the resolver blocked it (Pi-hole, corporate filter), or you asked for the wrong record type.
Can nslookup do reverse DNS?+
Yes. Just pass an IP address: nslookup 8.8.8.8 returns the PTR record (dns.google.).
Do I need admin rights to run nslookup?+
No. It runs as any user on Windows, macOS and Linux.
How do I get all record types at once?+
Use nslookup -type=any domain.com. Many resolvers now refuse ANY queries — dig or a DNS Lookup tool is more reliable for this.
What does 'Non-authoritative answer:' mean in the output?+
It means your resolver returned a cached value instead of asking the authoritative name server. Cached answers are usually fine but can be a few minutes to hours old.
Related articles
Browse all in IP & NetworkingWhat Is My IP Address? (Complete Guide 2026)
Read IP & NetworkingWhat Is DNS and How It Works (Beginner Guide)
Read IP & NetworkingIPv4 vs IPv6 Explained (Simple Comparison)
Read IP & NetworkingHow to Test Internet Speed Accurately
Read IP & NetworkingWhat Is a Proxy Server and How Does It Work? (2026 Guide)
Read IP & NetworkingWhat Is a Domain Name and How Does It Work? (2026 Guide)
ReadTry the related free tools
Hands-on utilities from DigiMetrics Hub that go with this guide.
DNS Lookup
Query DNS records for any domain instantly. Supports A, AAAA, MX, CNAME, TXT and more.
Open tool Network & IPReverse DNS
Perform a reverse DNS lookup to find the hostname associated with any IP address for free.
Open tool Network & IPWHOIS Lookup
Find domain registration details, owner info, expiry date and nameservers with our free WHOIS tool.
Open tool Network & IPWhat Is My IP
Instantly find your public IP address, location, ISP and timezone. Free, no signup required.
Open tool