Linux nslookup Command: Query DNS Names and Records
nslookup queries a domain or IP address on a DNS server. It supports simple lookups and interactive queries, but for detailed DNS response analysis, dig is often clearer.
What is the nslookup command?
If you provide a name as an argument, it outputs results non-interactively, and if executed without arguments, it enters interactive mode. The default server follows the system settings, and you can specify another DNS server with the last argument. Non-authoritative answer may indicate a cached response and is not immediately an error.
Basic syntax
nslookup [option] [name|IP] [DNS server]
The installed implementation and options may vary depending on the distribution. Check the current system description with man nslookup.
Examples
Domain address lookup
Queries the address from the configured DNS server.
nslookup example.com
Specify record type
Check the MX record that represents the mail server.
nslookup -type=MX example.com
Reverse DNS lookup
Check whether the PTR record of the IP address is registered.
nslookup 192.0.2.1
Check Which DNS Server Responded
nslookup queries the default DNS server. The results may show the server used along with the response address.
nslookup example.com
Example structure of the output (addresses are illustrative):
Server: 192.0.2.53 Name: example.com Address: 192.0.2.10
Do not confuse the Address in the answer with the Server address used for the query. The same name can return different values depending on the DNS server, cache, and timing. If you need a detailed comparison including record type and TTL, dig is more suitable.
Main Options and Format
| Options/Format | Description |
|---|---|
-type=format |
Select a record type such as A, AAAA, MX, or TXT. |
-query=format |
An alias that specifies the query record type. |
-timeout=seconds |
Adjusts the wait time for the DNS server response. |
Last server argument |
Query a specific DNS server instead of the default. |
No arguments |
Entering interactive mode. |
Precautions when using
Do not assume that the network connection has failed just because there is no DNS response. Check the server you are using, the record format, and the cache status. nslookup does not reproduce the system's /etc/hosts handling or all name resolution paths of the application.
Frequently Asked Questions
How do you exit interactive mode in nslookup?
You can exit by typing exit at the prompt or pressing Ctrl+D.
Official Documentation
The exact behavior of the options and implementation differences can be found in the official nslookup documentation.









