COMMAND

nslookupQuery DNS records

nslookup queries the Domain Name System from the command line. nslookup example.com returns the address your resolver has; nslookup -type=MX example.com returns mail servers; and adding a server address at the end (nslookup example.com 1.1.1.1) queries that server directly, which separates a broken resolver from a broken record.

BlackhawkHub Editorial · Updated

Purpose

nslookup (name server lookup) asks DNS questions directly, bypassing the browser and application caches. It confirms what a name resolves to, retrieves any record type, and can query a chosen server so you can tell whether a problem is with the record or with the resolver you normally use. The concepts are in the DNS record.

Non-interactive use

cmd
nslookup example.com
text
Server:  UnKnown
Address:  192.168.1.1

Non-authoritative answer:
Name:    example.com
Addresses:  2606:2800:21f:cb07:6820:80da:af6b:8b2c
            93.184.215.14

The first two lines identify the resolver used; the answer follows.

Query a specific record type

cmd
nslookup -type=MX example.com
nslookup -type=TXT example.com
nslookup -type=NS example.com
nslookup -type=AAAA example.com
nslookup -type=SOA example.com

Query a specific server

cmd
nslookup example.com 1.1.1.1
nslookup example.com 8.8.8.8

Comparing your default resolver with a public one separates "the record is wrong" from "my resolver is stale or misconfigured", which is central to diagnosing DNS propagation.

Reverse lookup

cmd
nslookup 93.184.215.14

Returns the PTR record, if one exists, for that address.

Interactive mode

Running nslookup with no argument enters an interactive session:

text
> set type=MX
> example.com
> server 9.9.9.9
> example.com
> exit

Useful for several queries in a row against changing servers.

Common mistakes

  • Trusting "Server: UnKnown". That only means nslookup could not reverse-resolve your resolver's address; the queries still work.
  • Using nslookup for scripting. Its output format is awkward to parse; Resolve-DnsName returns objects and is better for automation.
  • Forgetting the record type. Without -type, nslookup returns address records only, so a missing MX or TXT looks like "no answer".

PowerShell equivalent

Resolve-DnsName example.com -Type MX -Server 1.1.1.1 does the same with structured output. See Resolve-DnsName.

Frequently asked questions

How do I look up MX records with nslookup?

nslookup -type=MX example.com. The output lists mail exchangers with their preference values; lower preference is tried first. See port 25.

Why does nslookup say "Non-authoritative answer"?

The answer came from a resolver's cache rather than the domain's own authoritative server. It is normal and does not mean the answer is wrong. Query an authoritative server directly to get an authoritative answer.

How do I test whether my DNS server is the problem?

Query a different server explicitly: nslookup example.com 1.1.1.1. If that works and your default does not, your configured resolver is at fault.

Sources