IP & Networking 11 min readBy Mehadi ShawonPublished Updated

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.

Terminal window showing nslookup DNS query output with A, MX and TXT records
Quick answer

nslookup Command Examples: 15 Real-World DNS Queries

nslookup is a command-line tool built into Windows, macOS and Linux that queries DNS servers for records. Typical use is 'nslookup domain.com' for A records, 'nslookup -type=MX domain.com' for mail, and 'nslookup 8.8.8.8' for reverse lookups.

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
Terminal window showing nslookup DNS query output with A, MX and TXT records

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 Lookup

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

Ad Space

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

  1. If every query fails: your resolver is unreachable. Try nslookup digimetricshub.com 1.1.1.1.
  2. If one specific domain fails: check DNS Lookup online to confirm the record exists.
  3. If MX/TXT looks wrong after a change: DNS is cached — wait for TTL or flush your resolver.
  4. 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 Lookup

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

Ad Space

Try the related free tools

Hands-on utilities from DigiMetrics Hub that go with this guide.

All tools