Skip to main content
Home/Blog/Automation/nslookup Commands: DNS Lookups, Record Types & Reverse DNS (2026)
Automation

nslookup Commands: DNS Lookups, Record Types & Reverse DNS (2026)

Look up any DNS record from the command line with nslookup, PowerShell Resolve-DnsName, and dig. Query A, MX, TXT, and PTR records, specify a DNS server, and do reverse lookups — complete 2026 reference for Windows, macOS, and Linux.

By InventiveHQ Team
nslookup Commands: DNS Lookups, Record Types & Reverse DNS (2026)

Need to look up a domain's DNS records right now? Run the lookup in the tool below — or read on for every nslookup, PowerShell Resolve-DnsName, and dig command for Windows, macOS, and Linux.

DNS Lookup

Query DNS records with email security analysis and health scoring

Open the full DNS Lookup
Loading interactive tool...

Verified June 2026 · nslookup, dig & Resolve-DnsName on Windows 11/10, macOS & Linux


Quick Reference: Essential Commands

# Look up a domain's IP (A / AAAA records)
nslookup example.com

# Query a specific record type
nslookup -type=MX example.com
nslookup -type=TXT example.com

# Reverse lookup (IP -> hostname)
nslookup 8.8.8.8

# Ask a specific DNS server
nslookup example.com 1.1.1.1

Which command should you use?

Jump to the section you need below, or run a live lookup in the tool above.


nslookup: The Cross-Platform Classic

nslookup (name server lookup) ships with Windows, macOS, and Linux. It's the quickest way to answer "what does DNS say about this name?"

WindowsmacOSLinuxBuilt in — no install

nslookup Syntax Reference

CommandWhat it does
nslookup example.comForward lookup (A / AAAA)
nslookup -type=MX example.comMail server (MX) records
nslookup -type=TXT example.comTXT records (SPF, DKIM, verification)
nslookup -type=NS example.comAuthoritative name servers
nslookup -type=SOA example.comStart of Authority record
nslookup -type=CNAME www.example.comCanonical name (alias)
nslookup 8.8.8.8Reverse lookup (PTR)
nslookup example.com 1.1.1.1Query a specific DNS server

Interactive Mode

Running nslookup with no arguments opens interactive mode, handy for several lookups in a row:

nslookup
> set type=MX
> example.com
> set type=A
> example.org
> server 8.8.8.8
> example.net
> exit

Tip: Add the DNS server as a second argument (nslookup example.com 1.1.1.1) to bypass your local resolver. It's the fastest way to check whether a DNS change has propagated to a public resolver yet.


Resolve-DnsName: The PowerShell Way

On Windows, Resolve-DnsName returns structured objects you can filter, sort, and script — far nicer than parsing nslookup text.

Windows 10Windows 11Server 2012+Built in — no module

# Basic lookup
Resolve-DnsName example.com

# Specific record type
Resolve-DnsName example.com -Type MX
Resolve-DnsName example.com -Type TXT

# Reverse lookup
Resolve-DnsName 8.8.8.8

# Query a specific server and bypass the cache
Resolve-DnsName example.com -Server 1.1.1.1 -DnsOnly

# Just the IP addresses, scripting-friendly
(Resolve-DnsName example.com -Type A).IPAddress

dig: The Modern Standard on macOS & Linux

dig (Domain Information Groper) is the preferred tool on Unix-like systems — more detailed and more scriptable than nslookup.

macOSLinux⚠ Install on Windows (BIND tools)

# Clean answer only
dig example.com +short
dig example.com MX +short

# Full record with the answer section only
dig example.com ANY +noall +answer

# Reverse lookup
dig -x 8.8.8.8

# Query a specific server
dig @1.1.1.1 example.com

# Trace the full resolution path from the root servers
dig example.com +trace

Common DNS Record Types

TypePurpose
AMaps a name to an IPv4 address
AAAAMaps a name to an IPv6 address
CNAMEAlias pointing one name at another
MXMail servers and their priority
TXTFree-form text — SPF, DKIM, domain verification
NSAuthoritative name servers for the zone
SOAZone authority and serial/refresh timers
PTRReverse mapping (IP -> hostname)
SRVService location (host + port)
CAAWhich certificate authorities may issue certs

Troubleshooting: Common nslookup Messages

Each row is deep-linkable — share a specific message with …#dns-nxdomain, and the row highlights on arrival.

MessageMeaningFix
Non-existent domainNo record exists (NXDOMAIN)Check spelling, confirm the domain is registered, try another record type or server
DNS request timed outThe DNS server didn't respondCheck connectivity; try a public resolver: nslookup example.com 1.1.1.1
Default Server: UnKnownYour resolver has no reverse (PTR) recordCosmetic — ignore it, or specify a server explicitly
No response from serverThe queried server isn't answering on port 53Verify the server IP and that a firewall isn't blocking DNS
Query refusedThe server won't answer your query (REFUSED)You may not be authorized to query that resolver — use your own or a public one
Server failedThe resolver hit an error (SERVFAIL)Often a DNSSEC or upstream issue — try another resolver or dig +trace

Checking DNS Propagation

After changing a DNS record, query several public resolvers to see whether the change has spread:

nslookup example.com 1.1.1.1      # Cloudflare
nslookup example.com 8.8.8.8      # Google
nslookup example.com 9.9.9.9      # Quad9

If the resolvers disagree, the change is still propagating — DNS caches honor the record's TTL, so allow up to the TTL value (often 300–3600 seconds) before expecting consistency everywhere.


nslookup vs dig vs Resolve-DnsName

ToolPlatformBest for
nslookupWindows, macOS, LinuxQuick checks anywhere; universally available
Resolve-DnsNameWindowsScripting — returns objects, not text
digmacOS, Linux (installable on Windows)Detailed diagnostics, +trace, clean scripting

Frequently Asked Questions

Find answers to common questions

Run 'nslookup example.com'. nslookup returns the A (IPv4) and AAAA (IPv6) records for the domain, along with the DNS server that answered. To query a specific record type, add the type: 'nslookup -type=A example.com'.

Run 'nslookup -type=MX example.com' (or '-query=MX'). This returns the mail servers for the domain and their priority values. In PowerShell, use 'Resolve-DnsName example.com -Type MX'. On macOS/Linux, use 'dig example.com MX'.

Run 'nslookup 8.8.8.8' — nslookup automatically does a reverse (PTR) lookup when you give it an IP address. Explicitly: 'nslookup -type=PTR 8.8.8.8'. In PowerShell: 'Resolve-DnsName 8.8.8.8'. With dig: 'dig -x 8.8.8.8'.

Add the server as the second argument: 'nslookup example.com 8.8.8.8' queries Google's DNS instead of your default resolver. This is useful for confirming a record has propagated, or comparing your local resolver against a public one.

It means the DNS server has no record for the name you queried (NXDOMAIN) — the domain doesn't exist, isn't registered, or the record type you asked for isn't present. Check spelling, confirm the domain is registered, and try a different record type or DNS server.

nslookup couldn't resolve the name of your configured DNS server (it has no PTR record), which is cosmetic and doesn't affect lookups. You can ignore it, or specify a server explicitly: 'nslookup example.com 1.1.1.1'.

All three query DNS. nslookup ships with Windows, macOS, and Linux but is considered legacy. dig (Domain Information Groper) is the modern standard on macOS/Linux with richer output. Resolve-DnsName is the PowerShell cmdlet on Windows, with structured object output that's easy to script.

Use interactive mode and set debug: run 'nslookup', then 'set debug' (or 'set d2' for verbose), then enter the domain. For a one-liner with full detail, dig is better: 'dig example.com ANY +noall +answer' or 'dig example.com +trace' to follow the resolution path.

Transform Your IT with Automation

Streamline operations, reduce manual tasks, and improve security with intelligent automation.