Using nslookup to Diagnose DNS Problems: A Practical Guide
DNS translates domain names like example.com into IP addresses like 93.184.216.34 that computers actually use to connect. When a site won't load, email stops arriving, or a domain change doesn't seem to be taking effect, nslookup is usually the fastest way to check whether DNS is actually the problem — before looking anywhere else.
Basic Usage
The simplest check, run directly in Command Prompt (Windows) or Terminal (Linux/macOS):
nslookup example.com
This returns the IP address the domain currently resolves to. To test against a specific DNS server instead of your default (useful for checking whether a change has propagated everywhere yet):
nslookup example.com 8.8.8.8
Full Syntax
nslookup [-type=record_type] domain_name [dns_server]
-type=— specify which DNS record type to query (see below)domain_name— the domain you're checkingdns_server— optional, e.g.1.1.1.1for Cloudflare or8.8.8.8for Google, to bypass your system's default resolver
Interactive Mode
For checking several record types on the same domain without retyping it each time, run nslookup with no arguments to enter interactive mode:
> set type=mx
> example.com
> set type=ns
> example.com
> exit
DNS Record Types and What They're For
| Type | Purpose | Example command |
|---|---|---|
| A | Domain → IPv4 address | nslookup -type=a example.com |
| MX | Mail server for the domain | nslookup -type=mx example.com |
| NS | Which name servers manage the domain | nslookup -type=ns example.com |
| SOA | Zone's primary server and admin contact | nslookup -type=soa example.com |
| CNAME | Alias pointing to another domain name | nslookup -type=cname www.example.com |
| PTR (reverse) | IP address → domain name | nslookup 93.184.216.34 |
Diagnosing Common Problems
- Site unreachable: Check the A record first. If the returned IP doesn't match what it should be, the domain is likely pointing to the wrong server, or an old IP that hasn't updated yet.
- Email not arriving: Check MX records. A missing or incorrect MX record means mail has nowhere valid to route to.
- DNS change not taking effect everywhere: Query the same domain against multiple public DNS servers (8.8.8.8, 1.1.1.1, your ISP's default). If they return different results, the change is still propagating.
- Confirming who manages a domain: An NS record lookup shows the authoritative name servers, useful for confirming a DNS provider migration actually took effect.
Debug Mode
Adding -debug shows the full query and response, including TTL values:
nslookup -debug example.com
This is useful when a domain resolves but seems to be caching a stale value longer than expected — the TTL tells you how long that record is valid before it should be re-queried.
Automating Checks Across Multiple Domains
for domain in example.com google.com; do
nslookup $domain
done
Useful for a quick weekly script that confirms a batch of domains you manage are still resolving correctly.
nslookup vs. dig vs. host
| Tool | Best for |
|---|---|
| nslookup | Quick, cross-platform checks (built into Windows, Linux, macOS) |
| dig | More detailed output, preferred for scripting on Linux/macOS |
| host | Simplest one-line output for a fast lookup |
On Linux, nslookup requires the dnsutils package (sudo apt-get install dnsutils), which also installs dig — worth having both, since dig's output is easier to parse in scripts.
A Note on Trust
Avoid running lookups through random third-party web-based DNS tools for anything sensitive — you don't know what they log. Sticking to well-known public resolvers (Google's 8.8.8.8, Cloudflare's 1.1.1.1) or your organization's own DNS server keeps queries private and results reliable.
Found this article useful ? share it with your friends ..