nslookup Command Guide: Query DNS from Your Terminal

By MXToolbox Team · September 2, 2026

nslookup is a command-line tool for querying DNS records directly, without needing a browser-based tool. It’s built into Windows, macOS, and most Linux systems, which makes it the fastest way to check DNS when you already have a terminal open.

Basic syntax

nslookup <domain>

Example:

nslookup example.com

This returns the domain’s A (and often AAAA) record — the IP address(es) it resolves to.

Querying a specific record type

Use the -type= flag to query something other than the default A record:

nslookup -type=MX example.com
nslookup -type=TXT example.com
nslookup -type=NS example.com
nslookup -type=CNAME www.example.com

MX example output:

example.com   MX preference = 10, mail exchanger = mail1.example.com
example.com   MX preference = 20, mail exchanger = mail2.example.com

The “preference” value is the same as MX priority — lower numbers are tried first. See the MX record guide for a full explanation of how that ordering works.

Querying against a specific DNS server

By default, nslookup uses your system’s configured DNS resolver. You can override that by specifying a server directly as a second argument:

nslookup example.com 8.8.8.8

This is useful for confirming whether a DNS change has propagated to a specific public resolver, independent of what your local machine or ISP has cached.

Interactive mode

Running nslookup with no arguments drops you into an interactive prompt where you can run multiple queries and change settings without retyping the command each time:

nslookup
> set type=MX
> example.com
> set type=TXT
> example.com
> exit

This is handy when you’re checking several record types for the same domain back to back.

Common output fields explained

nslookup vs. dig vs. browser tools

ToolPlatformBest for
nslookupWindows, macOS, LinuxQuick checks, built-in everywhere
digmacOS, Linux (not native on Windows)Detailed/raw DNS troubleshooting
Browser DNS lookup toolAny deviceNo terminal needed, shareable results

If you’d rather not open a terminal, the free DNS Lookup tool covers the same record types (A, AAAA, MX, TXT, CNAME, NS) from your browser.

Troubleshooting with nslookup

If nslookup itself fails to return anything — timing out or showing “DNS server not responding” — that’s a resolver-level issue, not a problem with the domain you’re querying. See how to fix “DNS server not responding” for the fix.