Network
The nslookup command
Queries DNS to turn a name into an IP or the reverse, and to read records such as MX, NS or TXT. It is a quick diagnostic tool found on almost every system, although dig gives more detail.
Most useful options
-type <tipo>Record type: A (IPv4), AAAA (IPv6), MX (mail), NS, TXT, CNAME...[servidor]Queries a specific DNS server, e.g. 8.8.8.8 or 1.1.1.1, instead of your machine's.-query=AAAAAsks for AAAA (IPv6) records instead of A (IPv4).-debugShows every DNS packet sent and received. A lot of text, useful for debugging.-timeout <segundos>Time to wait for a reply before giving up, in seconds.Copy-ready examples
$ nslookup example.comResolves the name and shows the IP your network's DNS returns.Example output
Server: 192.168.1.1 Address: 192.168.1.1#53 Non-authoritative answer: Name: example.com Address: 93.184.215.14
$ nslookup -type=MX example.com 8.8.8.8Mail servers of the domain, querying Google DNS directly.$ nslookup -type=TXT example.comTXT records, where SPF and domain verification entries usually live.$ nslookup 93.184.215.14Reverse lookup: from IP to name.$ nslookup -query=AAAA example.comOnly the domain's IPv6 address.You can try them in the browser terminal: it does not touch your computer.
Common errors
| Message | Cause | Fix |
|---|---|---|
| ** server can't find nohost.invalid: NXDOMAIN | The domain does not exist in DNS: usually a typo or a domain that was never registered. | Check the spelling and try another DNS, such as 1.1.1.1, in case yours has a broken cache. |
| ** server can't find example.com: SERVFAIL | The DNS server you asked failed to resolve, for example because of a DNSSEC problem or its authoritative servers. | Try another server (nslookup name 8.8.8.8) before blaming the domain. |
| ;; connection timed out; no servers could be reached | No DNS server answers: there is no connection, a firewall blocks port 53, or the network is down. | Ping 8.8.8.8: if it answers, the problem is only the DNS you have configured. |
Typical mistakes
- The answer may come from the machine's cache: after changing a record, wait for the TTL.
Differences from similar commands
- dig: Shows the full DNS answer, with timings and the authority section. Better for scripts and detailed diagnosis.
- host: Compact, readable output: host example.com prints the IP in one line. Ideal for a quick lookup from the terminal.
whois: Queries domain registration data (owner, dates, name servers) instead of IPs.
FAQ
What does 'Non-authoritative answer' mean?
The answer comes from a cache, not from the server that manages the domain. It is normal for almost every query.
What is the difference between A and AAAA?
A returns an IPv4 address and AAAA an IPv6 one. If your network uses IPv6, check both.
How do I test a DNS server without changing my settings?
Pass it as the second argument: nslookup example.com 1.1.1.1. Your machine keeps using its usual DNS. Nothing changes on your network.
More Network commands
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course