What does nslookup do?
It asks a DNS server about a name and prints the answer. Its main advantage is availability: Windows has it built in, macOS includes it, and Linux gets it with the same package as dig. When a user says your site does not load, asking them to run nslookup shop.example.net shows in seconds which address their computer gets.
How do I run a basic lookup?
nslookup shop.example.net # Server: 127.0.0.53 # Address: 127.0.0.53#53 # # Non-authoritative answer: # Name: shop.example.net # Address: 203.0.113.25
The first block names the server that answered, the system's default resolver. "Non-authoritative" means it came from a cache, not from the domain's own name servers, which is normal for everyday lookups.
How do I ask for other record types?
| Goal | Command |
|---|---|
| Mail servers | nslookup -type=mx example.net |
| Text records such as SPF | nslookup -type=txt example.net |
| Name servers | nslookup -type=ns example.net |
| Zone details | nslookup -type=soa example.net |
| Reverse lookup | nslookup 203.0.113.25 |
On Windows the same syntax works in Command Prompt and PowerShell; -type may also be written -q or -querytype.
How do I ask a specific server?
Add the server as the second argument:
nslookup shop.example.net 8.8.8.8 nslookup shop.example.net ns1.dns-host.example
The second form asks the domain's authoritative server directly, which shows the current record without any cache. If the authoritative answer is new and the user's default answer is old, the change is correct and only waiting for caches to expire.
What is interactive mode?
Run nslookup without arguments and you get a prompt where settings persist between queries:
nslookup > server 1.1.1.1 > set type=mx > example.net > set type=a > www.example.net > set debug > exit
It is handy for checking many records against one server without retyping options. set debug prints the full response, including TTLs, which the normal output hides.
When is dig the better tool?
When precision matters. nslookup uses its own resolver logic, can behave slightly differently from the system's, and hides details such as TTLs and flags unless debug is on. dig prints the raw response, supports +trace from the root and DNSSEC checks, and its output is easier to compare between servers. A fair rule: nslookup for quick checks and for asking non-technical users, dig for diagnosing. The dig guide is The dig command.
What common answers mean
- "server can't find ...: NXDOMAIN": the name does not exist in DNS. Check spelling and the zone.
- "No answer": the name exists but has no record of the requested type, for example no MX.
- "connection timed out; no servers could be reached": the resolver is unreachable; on a server, check
/etc/resolv.confand outbound UDP and TCP port 53. - "SERVFAIL": the resolver could not get a valid answer, often a DNSSEC problem or broken delegation.
How does this help when moving a site to a new machine?
Lower the record's TTL a day before the move, change the A record to the new machine's address at switch time, and check with nslookup against both the authoritative server and a couple of public resolvers. Users who still reach the old box are on cached answers; the old machine should keep serving until the TTL has passed everywhere. Testing the new box before the switch is easy with curl's --resolve option, shown in Headers with curl.
How do I check DNS from the server itself?
Run the same lookups on the machine, because what the server resolves decides where it sends mail, which APIs it reaches and whether package mirrors work. nslookup api.partner.example on the box uses the resolver from /etc/resolv.conf. If it fails there but works on your laptop, the server's resolver configuration is the problem, not the record. Comparing with nslookup api.partner.example 9.9.9.9 on the same machine isolates it in one step.
Keep Reading
The dig command
Query DNS precisely with dig: record types, short answers, specific resolvers, full delegation traces, reverse lookups and DNSSEC checks.
OpenInstall dig on CentOS, Rocky, Alma
Add dig, nslookup and host to CentOS Stream 9, Rocky Linux 9 or AlmaLinux 9 with one package, and confirm the resolver they use.
OpenHeaders with curl
Show response headers, send or remove request headers, pick single header values and test caching, compression and virtual hosts with curl.
OpenRun a traceroute
Install and run traceroute on Linux, Windows and macOS, read each column of the output and tune probes, timeouts and hop limits.
OpenFAQ
Quick Answers
Yes. It is built in and works in Command Prompt and PowerShell.
Run nslookup -type=mx followed by the domain.
The answer came from a resolver cache rather than the domain's own name servers.
Add the server after the name, such as nslookup example.net 1.1.1.1.
nslookup for quick checks and Windows users; dig for detailed diagnosis with TTLs, traces and DNSSEC.