Support Library
nslookup Command Guide
nslookup asks a DNS server for records about a name or an IP address. It comes with Windows, macOS and most Linux distributions, and it can send each query to any server you choose, which makes it a quick way to compare answers and check reverse DNS.
The short answer
The basic form is nslookup [options] name [server]. With only a name, nslookup asks your computer's default DNS server for the name's addresses. Add -type= to ask for another record type, and add a server at the end to send the query somewhere else.
| Command | What it does |
|---|---|
| nslookup example.com | Addresses, from your default DNS server |
| nslookup example.com 1.1.1.1 | The same question, asked of Cloudflare |
| nslookup -type=MX example.com | Mail servers for the domain |
| nslookup 192.0.2.25 | Reverse lookup: which name owns this address? |
nslookup talks to a DNS server directly. It skips your hosts file (unless a local stub such as systemd-resolved answers from it) and ignores the encrypted DNS your browser may use, so its answer can differ from what an application on the same computer sees.
Two versions of the same command
There are two common implementations. Windows ships Microsoft's own nslookup, documented in the Windows Commands reference. macOS and Linux ship the version from ISC's BIND tools, the same package that provides dig and host. On Debian and Ubuntu it comes in bind9-dnsutils (or dnsutils), and on Fedora and RHEL in bind-utils.
The everyday commands in this guide work on both. The output looks a little different, and a few options exist on only one side. Where that matters, the examples say which one they show.
| Behavior | Windows nslookup | BIND nslookup (macOS, Linux) |
|---|---|---|
| Default server | The first DNS server of the active network adapter | The first nameserver line in /etc/resolv.conf |
| First lines of output | Looks up the server's own name and prints it, or UnKnown | Prints the server address and port, such as 1.1.1.1#53 |
| Search suffixes | May append the adapter's DNS suffixes to the name | Uses the search list for names without a trailing dot; a dotted name is tried as typed first |
| Newer record types | May show types such as CAA or HTTPS as raw data, or not at all | Decodes any type the BIND libraries know |
| Zone listing | Has an interactive ls command | No ls; use dig AXFR |
Forward and reverse lookups
A forward lookup starts with a name and asks for data stored under it. Most of the time that means an address: an A record for IPv4 or an AAAA record for IPv6. It is what every browser does before it connects to a website.
A reverse lookup starts with an IP address and asks which name belongs to it. DNS cannot search for an address directly, so the address is rewritten as a name under a special zone, and the resolver asks for the PTR (pointer) record there. For IPv4, the four numbers are reversed and in-addr.arpa is added. For IPv6, each hexadecimal digit becomes its own label, in reverse, under ip6.arpa. nslookup does the rewriting for you whenever you give it an address.
| Forward lookup | Reverse lookup | |
|---|---|---|
| You start with | A name, such as mail.example.com | An address, such as 192.0.2.25 |
| Name actually queried | mail.example.com | 25.2.0.192.in-addr.arpa |
| Record type | A, AAAA, or any other type you ask for | PTR |
| Who controls the answer | The owner of the domain, through its DNS provider | The holder of the address block, usually a hosting provider or ISP |
| nslookup command | nslookup mail.example.com | nslookup 192.0.2.25 |
Here is a forward lookup followed by a reverse lookup with BIND's nslookup:
$ nslookup mail.example.com
Server: 192.168.1.1
Address: 192.168.1.1#53
Non-authoritative answer:
Name: mail.example.com
Address: 192.0.2.25
Name: mail.example.com
Address: 2001:db8::25
$ nslookup 192.0.2.25
25.2.0.192.in-addr.arpa name = mail.example.com.
$ nslookup 8.8.8.8
8.8.8.8.in-addr.arpa name = dns.google.
The two directions are separate records, kept in separate zones by people who may never talk to each other. A name can point to an address whose PTR record names something else, or nothing at all. When both directions agree, as they do above, the setup is called forward-confirmed reverse DNS. Mail servers check for it, which is why a missing PTR record is a common cause of rejected mail. Reverse DNS and PTR Records explains who sets these records and how to get one changed.
Run nslookup on the address, then run it again on the name it returns. If the second answer includes the address you started with, forward and reverse DNS match.
Asking a specific DNS server
By default nslookup sends every query to your computer's configured DNS server, which is often your router or a corporate resolver. To ask a different server, add its address or name as the last argument. This is the most useful thing nslookup does, because comparing servers is how you tell a local problem from a global one.
| Command | What it does |
|---|---|
| nslookup example.com 1.1.1.1 | Cloudflare |
| nslookup example.com 8.8.8.8 | Google Public DNS |
| nslookup example.com 9.9.9.9 | Quad9 |
| nslookup example.com 2606:4700:4700::1111 | Cloudflare over IPv6 |
| nslookup -type=MX example.com 8.8.8.8 | Options go before the name |
| nslookup example.com ns1.example.net | A server given by name |
If you give a server by name, nslookup first resolves that name using your default server, then sends the real query to the address it found. BIND's nslookup also accepts -port= for a server listening on a port other than 53, which is handy for testing a resolver on a lab machine.
In interactive mode, the server command changes the server for the rest of the session. Both versions also have lserver, which does the same thing but resolves the new server's name with the server you started with. That matters when the server you just switched to cannot resolve names, such as an authoritative server.
Which server to ask
| Server to query | What its answer tells you |
|---|---|
| Your default server | What your computer and network see right now, including any filtering or internal-only names. |
| A public resolver (1.1.1.1, 8.8.8.8, 9.9.9.9) | What most of the internet sees. Some of these answers may still be cached from before your last change. |
| The domain's authoritative name server | What the domain owner has published, with no cache in between. This is the source of truth after a change. |
To find the authoritative servers, ask for the domain's NS records, then query one of them directly:
$ nslookup -type=NS example.com
Non-authoritative answer:
example.com nameserver = ns1.example.net.
example.com nameserver = ns2.example.net.
$ nslookup www.example.com ns1.example.net
Server: ns1.example.net
Address: 198.51.100.53#53
Name: www.example.com
Address: 192.0.2.80
Notice that the second answer has no “Non-authoritative answer” line. That is how nslookup shows that the reply came from a server responsible for the zone. If an authoritative server answers with REFUSED or times out, it may not be serving the zone at all, a problem described in Lame Delegation.
Looking up other record types
Set the record type with -type=. Both versions also accept the shorter -q=. The type is not case-sensitive.
| Type | What it holds | Command |
|---|---|---|
| A / AAAA | IPv4 / IPv6 addresses | nslookup -type=AAAA example.com |
| CNAME | An alias pointing to another name | nslookup -type=CNAME www.example.com |
| MX | Mail servers and their preference | nslookup -type=MX example.com |
| NS | The zone's name servers | nslookup -type=NS example.com |
| SOA | Zone serial number and timers | nslookup -type=SOA example.com |
| TXT | SPF, DMARC and verification strings | nslookup -type=TXT _dmarc.example.com |
| SRV | Service host and port | nslookup -type=SRV _sip._tcp.example.com |
| PTR | Name for an address | nslookup -type=PTR 25.2.0.192.in-addr.arpa |
| CAA | Which certificate authorities may issue | nslookup -type=CAA example.com (BIND) |
Avoid relying on -type=ANY. Many servers now return a single record, or a short placeholder, instead of everything they hold, as allowed by RFC 8482. Ask for each type you care about instead. DNS Record Types Explained describes each type in more depth.
An SOA lookup against each authoritative server is a quick way to check that they all serve the same version of a zone. In a classic primary and secondary setup, differing serial numbers mean at least one server has not picked up the latest change. Zones served by several independent primaries, such as multi-provider setups or Active Directory-integrated DNS, can keep their own serials, so compare the actual records there instead.
$ nslookup -type=SOA example.com ns2.example.net
Server: ns2.example.net
Address: 203.0.113.53#53
example.com
origin = ns1.example.net
mail addr = hostmaster.example.com
serial = 2026102201
refresh = 7200
retry = 3600
expire = 1209600
minimum = 300
Reading the output
Every reply has the same parts. Here is the same lookup on Windows, where the differences from BIND's output are easiest to spot:
C:\> nslookup www.example.com
Server: UnKnown
Address: 192.168.1.1
Non-authoritative answer:
Name: www.example.com.cdn.example.net
Addresses: 2001:db8::80
192.0.2.80
Aliases: www.example.com
- Server and Address name the DNS server that answered. Check this line first: many confusing results come from asking a server you did not mean to ask. On Windows, UnKnown only means the server's address has no PTR record. It is not an error.
- Non-authoritative answer means the reply came from a recursive resolver rather than from the domain's own name servers. It is normal and usually correct, but it may be up to one TTL old.
- Name is the final name that holds the data. If the name you typed is an alias, Windows lists the alias under Aliases, and BIND prints a canonical name = line before the answer.
- Address or Addresses lists the A and AAAA records. A plain lookup asks for both types, so you may see IPv4 and IPv6 together.
nslookup hides the TTL and the header flags by default. Turn on debug output with -debug (or set debug in interactive mode) to see the response code, whether the answer was authoritative, and how many seconds each record has left in the cache.
Authoritative and non-authoritative answers
An authoritative answer comes from a server that holds the zone itself. A non-authoritative answer comes from a resolver that fetched the data from an authoritative server, possibly some time ago, and cached it. When you have just changed a record, the authoritative servers show the new value straight away, while resolvers keep showing the old one until the cached copy's TTL runs out. An old cached answer can persist for its TTL, but a correct answer from one authoritative server does not rule out delegation, DNSSEC, policy or reachability faults. Check those and the other authoritative servers before prescribing a wait. Incorrect authoritative data needs correction at the provider. Authoritative DNS vs Recursive DNS and DNS TTLs and Caching Explained go into more detail.
Common errors
| Message | What it means |
|---|---|
| server can't find … NXDOMAIN (Windows: Non-existent domain) | The name does not exist at all. Check the spelling, and on Windows check that a search suffix was not added. |
| *** Can't find …: No answer | The name exists but has no record of the type you asked for. This is called NODATA. |
| server can't find … SERVFAIL (Windows: Server failed) | The resolver could not get a usable answer. Broken DNSSEC and unreachable name servers are the usual causes. |
| REFUSED | The server will not answer this question for you, for example an authoritative server asked about a zone it does not host. |
| connection timed out; no servers could be reached (Windows: DNS request timed out) | No reply came back. The server may be down, or a firewall may be blocking port 53. |
The response codes are explained in NXDOMAIN vs NODATA vs REFUSED and DNS SERVFAIL Explained.
Interactive mode
Run nslookup with no arguments, or with - followed by a server, to get a > prompt. Anything you type that is not a command is treated as a name to look up, and settings stay in place between queries. That saves typing when you are checking several names or record types against the same server.
$ nslookup
> server 9.9.9.9
Default server: 9.9.9.9
Address: 9.9.9.9#53
> set type=MX
> example.com
…
> example.org
…
> set type=TXT
> _dmarc.example.com
…
> exit
| Command | What it does |
|---|---|
| server address | Send later queries to this server |
| set type=TYPE | Change the record type (set q= also works) |
| set debug / set nodebug | Show or hide the full reply, including TTLs and flags |
| set norecurse | Ask the server not to query other servers; a resolver then answers from what it already holds, refers you elsewhere, or refuses |
| set vc | Use TCP instead of UDP |
| set timeout=N / set retry=N | Wait longer, or retry more, on slow or lossy links |
| set all | Show the current settings and default server |
| exit | Leave interactive mode |
The same settings work on the command line with a dash, such as nslookup -timeout=10 -retry=3 example.com. Windows also offers ls -d example.com, which attempts a zone transfer to list every record. Almost every public server refuses it, as it should; a server that allows transfers to anyone is leaking its zone.
Platform quirks that change the answer
On Linux, nslookup is part of the bind-utils (Fedora, RHEL) or dnsutils / bind9-dnsutils (Debian, Ubuntu) package. Minimal installs and containers often leave it out, so install that package if the command is missing.
Windows: DNS suffixes and the trailing dot
Windows nslookup may append the connection's DNS suffixes, such as corp.example.com, to the name before sending it. On a work network, a query for intranet becomes intranet.corp.example.com, which is often what you want. It can also produce surprises, such as a wildcard record in the internal domain answering for a public name. End the name with a dot, as in nslookup example.com., to say the name is complete and stop suffixes from being added. BIND's nslookup on macOS and Linux can do the same with its search list: a name without a dot gets the suffixes straight away, and a dotted name such as api.prod gets them if the name as typed is not found. The trailing dot works there too. Turn on -debug to see exactly which names were tried.
macOS: nslookup is not what apps use
On macOS, nslookup reads /etc/resolv.conf, but applications use the system resolver, which also honors per-domain rules from VPN clients and files in /etc/resolver/. If a VPN sends internal names to an internal server, nslookup may not follow that rule. Run scutil --dns to see the real configuration, or dscacheutil -q host -a name example.com to resolve a name the way apps do.
Linux: the local stub resolver
On many Linux systems, /etc/resolv.conf points at a local stub such as systemd-resolved on 127.0.0.53, so the Server line shows that address rather than your real upstream server. Run resolvectl status to see which servers the stub forwards to, or name a server explicitly.
Everywhere: hosts files and encrypted DNS
nslookup does not read the hosts file itself. The one exception is a local stub: systemd-resolved answers from /etc/hosts, so on Linux systems that use it, hosts entries can show up in nslookup too. nslookup also cannot send DNS over HTTPS or DNS over TLS itself, so it never sees the answers a browser gets from its own encrypted DNS setting. Operating-system encrypted DNS is different: if a local stub such as systemd-resolved forwards over TLS, nslookup's queries to that stub go out encrypted too. If ping or a browser reaches a different address than nslookup reports, check the hosts file and the encrypted DNS settings first. Why does DNS work on one network but not another? walks through the other usual causes, including split-brain DNS.
A troubleshooting routine
- Run nslookup name and note which server answered and what it said.
- Ask two public resolvers, such as 1.1.1.1 and 8.8.8.8. If they agree with each other but not with your default server, investigate caching, filtering and internal zones, while also checking validation and authoritative reachability along the failing resolver’s path.
- Find the NS records and ask each authoritative server. If they disagree with each other, compare SOA serials (or, with multiple independent providers, the records themselves). If they all agree but the resolvers do not, check remaining cache TTLs, DNSSEC, delegation and resolver policy; wait only when a healthy cached answer explains the difference.
- If a validating resolver returns SERVFAIL but the authoritative servers answer, suspect DNSSEC. Debugging DNSSEC validation errors covers the next steps.
- For mail problems, check MX, then the A and AAAA records of each mail host, then reverse DNS of each address.
When you need TTLs, flags, DNSSEC records or the full delegation path, switch to dig. nslookup vs dig compares the two, and the dig Command Deep Dive covers dig's options. On Windows, PowerShell's Resolve-DnsName is another option that returns structured output and accepts -Server and -Type parameters.
How DNS Panopticon helps
Domain Visualizer runs the lookups you would otherwise type one at a time. It queries a domain's records through public resolvers, so you can check MX, TXT, CAA and DNSSEC in one place and then use nslookup to confirm what your own network sees. Website Recon looks up the network that holds each of a site's addresses, which tells you who controls their reverse DNS. If you run your own zones, export one and load it into Zone Analyzer to review every record, including PTR records, before you start querying servers.
FAQ
How do I make nslookup use a specific DNS server?
Put the server after the name you are looking up, for example nslookup example.com 1.1.1.1. In interactive mode, type server 1.1.1.1 and every later query goes to that server until you change it or exit.
What does Non-authoritative answer mean in nslookup?
It means the server that answered is not one of the domain's own name servers. It is usually a recursive resolver answering from its cache or after asking the authoritative servers for you. The data is normally correct, but it can be up to one TTL old.
Does nslookup read the hosts file?
Not by itself. nslookup sends DNS queries straight to a DNS server, so the hosts file is skipped unless that server is a local stub, such as systemd-resolved on Linux, that answers from it. Browsers and ping use the operating system resolver, which does read the hosts file, so they can see a different answer.
How do I do a reverse lookup with nslookup?
Give nslookup an IP address instead of a name, for example nslookup 8.8.8.8. It builds the in-addr.arpa or ip6.arpa name for you and asks for the PTR record, which holds the hostname for that address.