Look Up a Domain
nslookup example.com
The output has two parts. The first two lines name the DNS server that answered and its address, followed by #53, the DNS port. On Ubuntu that is often 127.0.0.53, the local systemd-resolved stub, which forwards the question. Below that come the name and its IPv4 and IPv6 addresses.
If the command is missing, install it with sudo apt install bind9-dnsutils on Debian and Ubuntu or sudo dnf install bind-utils on AlmaLinux and Rocky Linux. The same commands install dig.
Look Up a Record Type
nslookup -type=mx example.com
nslookup -type=txt example.com
nslookup -type=ns example.com
nslookup -type=soa example.com
nslookup -type=aaaa example.com
-type= picks the record type; -query= does the same. Options go before the name. Type names are not case sensitive. The meaning of each type is in DNS record types explained.
Ask a Specific DNS Server
nslookup example.com resolver_ip
nslookup -type=mx example.com resolver_ip
A second argument after the name chooses the server to ask; replace resolver_ip with its address. Asking two different resolvers is a quick way to see whether a recent change has reached both. Asking the domain's own name server shows what the zone contains, without any cache.
What "Non-authoritative Answer" Means
This line appears above most answers and is not an error. It means the answer came from a resolver, usually from its cache, and not directly from a name server that holds the zone. To get an authoritative answer, look up the domain's name servers with -type=ns and pass one of their addresses as the server to ask.
Reverse Lookup
nslookup 203.0.113.10
Given an IP address, nslookup asks for its PTR record and prints the name, if one is set. The reply shows the reversed address followed by in-addr.arpa, which is how reverse names are stored. See what is reverse DNS for why this record matters for mail.
Interactive Mode
Run nslookup without arguments to get a > prompt and ask several questions in a row:
nslookup
> server resolver_ip
> set type=txt
> example.com
> set type=mx
> example.com
> exit
server changes the DNS server for the rest of the session, and set type= changes the record type. set debug prints more of each reply, including the TTL.
Common Messages
- NXDOMAIN: the server says the name does not exist. Check the spelling and that the zone has the record.
- SERVFAIL: the resolver could not get an answer, often because of a broken delegation or DNSSEC failure.
- No answer: the name exists but has no record of the type you asked for.
- Connection timed out: no server replied. On a server that cannot resolve anything, see temporary failure in name resolution.
nslookup vs dig
| nslookup | dig | |
|---|---|---|
| Output | Short, readable | Full DNS reply |
| TTL and flags | Only in debug mode | Always shown |
| Trace delegation | No | +trace |
| Scripts | Awkward | +short |
nslookup is fine for a quick check. When you need the TTL, the status code, or the path through the name servers, use the dig command. A third tool, host, prints one line per record and is installed along with them.