nslookup Command in Linux: Query DNS Records

When a website does not load or email stops arriving, the first thing to check is whether the domain resolves to the correct address. The nslookup command is a quick way to query DNS servers and inspect the records behind a domain name.
nslookup ships with most Linux distributions and works on macOS and Windows as well. It supports both one-off queries from the command line and an interactive mode for running multiple lookups in a row.
This guide explains how to use nslookup with practical examples covering record types, reverse lookups, and troubleshooting.
Syntax
nslookup [OPTIONS] [NAME] [SERVER]NAME- The domain name or IP address to look up.SERVER- The DNS server to query. If omitted,nslookupuses the server configured in/etc/resolv.conf.OPTIONS- Query options such as-type=MXor-debug.
When called without arguments, nslookup starts in interactive mode.
Installing nslookup
nslookup is part of the BIND DNS utilities. Standard Ubuntu and Debian installations include it, but minimal systems, container images, and many cloud images do not. To check whether it is available, run:
nslookup -versionThe output shows the BIND version the tool comes from:
nslookup 9.20.24-1ubuntu0.5-UbuntuIf the tool is missing, the shell prints nslookup: command not found. There is no package named nslookup, so sudo apt install nslookup fails with Unable to locate package nslookup. Install the package that provides it instead.
Install nslookup on Ubuntu, Debian, and Derivatives
sudo apt update && sudo apt install bind9-dnsutilsThe package used to be called dnsutils. On Debian 13 and Ubuntu 26.04, dnsutils is a virtual package, and apt installs bind9-dnsutils when you ask for it.
Install nslookup on Fedora, RHEL, and Derivatives
sudo dnf install bind-utilsInstall nslookup on Arch Linux
sudo pacman -S bindThe nslookup command is bundled with the same packages that provide dig
.
Look Up a Domain Name
The simplest use is passing a domain name as an argument:
nslookup linux.orgServer: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
Name: linux.org
Address: 104.26.14.72
Name: linux.org
Address: 104.26.15.72
Name: linux.org
Address: 172.67.73.26
Name: linux.org
Address: 2606:4700:20::681a:f48
Name: linux.org
Address: 2606:4700:20::ac43:491a
Name: linux.org
Address: 2606:4700:20::681a:e48The first two lines show the DNS server that answered the query. Everything under “Non-authoritative answer” is the actual result. In this case, linux.org resolves to three IPv4 and three IPv6 addresses. Without a record type, nslookup looks up the A records first and then the AAAA records.
“Non-authoritative” means the responding DNS server is not authoritative for the queried name. The resolver may have returned cached data or fetched the records while handling your query.
Query a Specific DNS Server
By default, nslookup queries the resolver configured in /etc/resolv.conf. To query a different server, add it as the last argument.
For example, to query Google’s public DNS:
nslookup linux.org 8.8.8.8Server: 8.8.8.8
Address: 8.8.8.8#53
Non-authoritative answer:
Name: linux.org
Address: 104.26.15.72
Name: linux.org
Address: 172.67.73.26
Name: linux.org
Address: 104.26.14.72
Name: linux.org
Address: 2606:4700:20::ac43:491a
Name: linux.org
Address: 2606:4700:20::681a:f48
Name: linux.org
Address: 2606:4700:20::681a:e48This is useful when you want to compare results across different resolvers or verify whether a DNS change has propagated to public servers.
Query Record Types
Without the -type option, nslookup asks for A and AAAA records. To query a different record type, pass it with -type. If you are not sure what a record type is used for, see our DNS record types guide
.
MX Records (Mail Servers)
MX records identify the mail servers responsible for receiving email for a domain:
nslookup -type=mx google.comServer: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
google.com mail exchanger = 10 smtp.google.com.
Authoritative answers can be found from:The number before the mail server hostname is the priority. A lower number means higher priority.
The Authoritative answers can be found from: line starts a section for the domain’s name servers and their addresses. Depending on the resolver you use, the section is either filled in or left empty, as in this example.
NS Records (Name Servers)
NS records show which name servers are authoritative for a domain:
nslookup -type=ns google.comServer: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
google.com nameserver = ns1.google.com.
google.com nameserver = ns2.google.com.
google.com nameserver = ns3.google.com.
google.com nameserver = ns4.google.com.
Authoritative answers can be found from:TXT Records
TXT records store arbitrary text data, commonly used for SPF, DKIM, and domain ownership verification:
nslookup -type=txt google.com;; Truncated, retrying in TCP mode.
Server: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
google.com text = "v=spf1 include:_spf.google.com ~all"
google.com text = "facebook-domain-verification=22rm551cu4k0ab0bxsw536tlds4h95"
google.com text = "docusign=05958488-4752-4ef2-95eb-aa7ba8a3bd0e"The output may include many entries. The example above shows a subset of the TXT records returned for google.com.
The ;; Truncated, retrying in TCP mode. line appears when the answer does not fit in a single UDP packet. nslookup then repeats the query over TCP and prints the full result.
AAAA Records (IPv6)
AAAA records return the IPv6 address of a domain:
nslookup -type=aaaa google.comServer: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
Name: google.com
Address: 2a00:1450:4017:818::200eSOA Record (Start of Authority)
The SOA record contains administrative information about the domain, including the primary name server, the responsible email address, and timing parameters for zone transfers:
nslookup -type=soa google.comServer: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
google.com
origin = ns1.google.com
mail addr = dns-admin.google.com
serial = 897592583
refresh = 900
retry = 900
expire = 1800
minimum = 60
Authoritative answers can be found from:The serial number increments each time the zone is updated. DNS secondaries use it to decide whether they need a zone transfer.
CNAME Records
CNAME records point one domain name to another:
nslookup -type=cname www.github.comServer: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
www.github.com canonical name = github.com.
Authoritative answers can be found from:The output shows that www.github.com is an alias and github.com is the canonical name it points to. If the name you query does not have a CNAME record, nslookup prints *** Can't find github.com: No answer instead.
ANY Queries
To ask the DNS server for an ANY response, use -type=any:
nslookup -type=any google.com 1.1.1.1Server: 1.1.1.1
Address: 1.1.1.1#53
** server can't find google.com: NOTIMPANY queries do not reliably return every record type for a domain. RFC 8482 allows servers to answer them with a minimal response. Cloudflare’s 1.1.1.1 refuses them with NOTIMP, as shown above.
Other servers may return only part of the records. When you need the full picture, query each record type separately.
Reverse DNS Lookup
A reverse lookup finds the hostname associated with an IP address. Pass an IP address instead of a domain name:
nslookup 208.118.235.148148.235.118.208.in-addr.arpa name = ip-208-118-235-148.twdx.net.
Authoritative answers can be found from:Reverse lookups query PTR records. They are useful for verifying that an IP address maps back to the expected hostname, which matters for mail server configuration and security checks.
Interactive Mode
Running nslookup without arguments starts an interactive session where you can run multiple queries without retyping the command:
nslookup>At the > prompt, type a domain name to look it up:
> linux.org
Server: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
Name: linux.org
Address: 104.26.14.72
Name: linux.org
Address: 104.26.15.72
Name: linux.org
Address: 172.67.73.26
Name: linux.org
Address: 2606:4700:20::681a:e48
Name: linux.org
Address: 2606:4700:20::ac43:491a
Name: linux.org
Address: 2606:4700:20::681a:f48You can change query settings during the session with the set command. For example, to switch to MX record lookups and then query a domain:
> set type=mx
> google.com
Server: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
google.com mail exchanger = 10 smtp.google.com.
Authoritative answers can be found from:To change the DNS server:
> server 8.8.8.8
Default server: 8.8.8.8
Address: 8.8.8.8#53You can also choose the server when you start the session. Pass a hyphen in place of the domain name, followed by the server address:
nslookup - 8.8.8.8Every lookup in that session goes to 8.8.8.8 until you switch to another server with the server command.
Type exit to leave interactive mode.
Interactive mode is convenient when you need to test several domains or record types in a row without running separate commands each time.
Debugging DNS Issues
The -debug option shows the full query and response details, including TTL values and additional sections that nslookup normally hides:
nslookup -debug linux.orgThe beginning of the output will look something like this:
Server: 127.0.0.53
Address: 127.0.0.53#53
------------
QUESTIONS:
linux.org, type = A, class = IN
ANSWERS:
-> linux.org
internet address = 172.67.73.26
ttl = 300
-> linux.org
internet address = 104.26.14.72
ttl = 300
-> linux.org
internet address = 104.26.15.72
ttl = 300
AUTHORITY RECORDS:
ADDITIONAL RECORDS:
------------The QUESTIONS block shows what nslookup asked for. Each ttl value is the number of seconds the record can stay in the resolver cache. After this block, you will see the normal A answer, followed by a second debug block and answer for the AAAA query.
The debug output is verbose, but it is helpful when you need to see TTL values, check whether answers are authoritative, or trace unexpected behavior.
Common Options
The options below cover most lookups. Place them before the domain name. If you add an option after the name, nslookup ignores it.
-type=TYPE- Query a specific record type, such asmx,ns,txt, oraaaa.-query=TYPEdoes the same thing.-port=PORT- Send the query to a port other than 53.-timeout=SECONDS- Set how many seconds to wait for a reply.-retry=NUMBER- Set how many times to send the query before giving up.-vc- Send the query over TCP instead of UDP.-debug- Print the full query and response details.-version- Print the version and exit.
For example, to give a slow server two seconds per attempt and try only twice, run:
nslookup -timeout=2 -retry=2 linux.org 1.1.1.1nslookup vs dig
Both nslookup and dig
query DNS servers, but they differ in output and capabilities:
nslookupproduces simpler, more readable output. It also has an interactive mode that is convenient for quick checks.digprovides detailed, structured output with sections (QUESTION, ANSWER, AUTHORITY, ADDITIONAL) and supports advanced options like+tracefor tracing the full resolution path and+dnssecfor requesting DNSSEC records.
For quick lookups and basic troubleshooting, nslookup is often faster to type and read. For in-depth DNS debugging, dig gives you more control and detail. If you only need a one-line answer, the host command
is shorter than both.
Troubleshooting
nslookup: command not found
The BIND utilities are not installed. Install bind9-dnsutils on Ubuntu and Debian or bind-utils on Fedora and RHEL, as shown in the installation section
.
nslookup returns NXDOMAIN
The domain does not exist or is misspelled. In this case, nslookup prints ** server can't find example.com: NXDOMAIN. Verify the domain name and check that it is registered.
nslookup returns No answer
The name exists, but it has no record of the type you asked for. For example, nslookup -type=cname github.com prints *** Can't find github.com: No answer. github.com is not an alias, so it has no CNAME record. Check the record type, or run the query again without -type.
nslookup returns SERVFAIL
The DNS server could not process the query. Try a different resolver to isolate the problem:
nslookup linux.org 1.1.1.1If public resolvers return the correct answer, the issue is with your configured resolver.
Timed out; no servers could be reached
This means nslookup could not contact the DNS server. Current BIND releases print ;; communications error to 192.0.2.1#53: timed out for each attempt, followed by ;; no servers could be reached. Older releases print ;; connection timed out; no servers could be reached instead. Check your network connection and verify that /etc/resolv.conf contains a reachable name server. A firewall may also be blocking outbound DNS traffic on port 53.
Non-authoritative answer appears on every query
This is normal when you query a recursive resolver. The responding server is not authoritative for the queried name, but it can still return the correct records. The label does not tell you whether the answer came from its cache.
Quick Reference
For a printable quick reference, see the nslookup cheatsheet .
| Task | Command |
|---|---|
| Look up a domain | nslookup example.com |
| Query a specific DNS server | nslookup example.com 8.8.8.8 |
| Query MX records | nslookup -type=mx example.com |
| Query NS records | nslookup -type=ns example.com |
| Query TXT records | nslookup -type=txt example.com |
| Query AAAA (IPv6) records | nslookup -type=aaaa example.com |
| Query SOA record | nslookup -type=soa example.com |
| Query CNAME record | nslookup -type=cname example.com |
Run an ANY query | nslookup -type=any example.com |
| Reverse DNS lookup | nslookup 192.0.2.1 |
| Start interactive mode | nslookup |
| Start interactive mode with a server | nslookup - 8.8.8.8 |
| Set a timeout | nslookup -timeout=2 example.com |
| Enable debug output | nslookup -debug example.com |
FAQ
Can I use nslookup to check DNS propagation?
Yes. Query the same domain against several public DNS servers and compare the results with the intended record on the domain’s authoritative name servers. For example, run nslookup example.com 8.8.8.8, nslookup example.com 1.1.1.1, and nslookup example.com 9.9.9.9. A resolver that still returns the old value may have an unexpired cached record. Different answers alone do not prove incomplete propagation, because services can return different addresses based on geographic location.
Is nslookup deprecated?
The ISC (the organization behind BIND) once marked nslookup as deprecated in favor of dig, but later reversed that decision. nslookup is actively maintained and included in current BIND releases. It remains a practical tool for quick DNS lookups.
What does “Non-authoritative answer” mean?
It means the responding server is not authoritative for the queried name. A recursive resolver can return this label both for cached records and for records it has just fetched. If it serves cached data after a recent DNS change, the answer may still contain the old value until the cache expires.
Conclusion
The nslookup command is a quick way to query DNS records from the command line. Use -type to look up MX, NS, TXT, AAAA, and other record types, and pass a server argument to test against a specific resolver. For deeper DNS debugging, pair it with dig
. To look up domain ownership and registration details instead of DNS records, use the whois command
.
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 1000+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page