Nslookup Command in Linux with Examples
Nslookup (stands for “Name Server Lookup”) is a useful command for getting information from the DNS server. It is a network administration tool for querying the Domain Name System (DNS) to obtain domain name or IP address mapping or any other specific DNS record. It is also used to troubleshoot DNS-related problems.
In easy words, imagine the internet as a giant neighborhood. Websites are like houses, but instead of street names, they have easy-to-remember addresses like “google.com”. However, computers communicate using numbers, so they need a way to find these houses. That’s where DNS comes in. It acts like a phonebook, translating those friendly website names into numerical addresses (IP addresses) that computers can understand.
Now, the nslookup
command is like a special tool you can use to explore this phonebook. It lets you ask questions about websites and how they’re connected. You can use it to:
- Look up a website’s address: Just like looking up a phone number in a phonebook, you can use
nslookup
to find the IP address of a website. - Troubleshoot problems: If you’re having trouble accessing a website,
nslookup
can help you pinpoint where the issue might lie. - Learn more about domain configurations: By using
nslookup
, you can discover details about a website’s domain, such as the servers responsible for managing it.
Syntax of the nslookup Command in Linux
The syntax of the nslookup
command is relatively straightforward, typically taking the form:
nslookup [option] [domain]
Where:
[options]
refer to additional parameters that modify the behavior of the command.[domain]
denotes the domain name or IP address to be queried.
Options of nslookup command:
Options | Description |
---|---|
-domain=[domain-name] | allows you to change the default DNS name. |
-debug | enables the display of debugging information. |
-port=[port-number] | Use the -port option to specify the port number for queries. By default, nslookup uses port 53 for DNS queries |
-timeout=[seconds] | you can specify the time allowed for the DNS server to respond. By default, the timeout is set to a few seconds |
-type=a | Lookup for a record We can also view all the available DNS records for a particular record using the -type=a option |
-type=any | Lookup for any record We can also view all the available DNS records using the -type=any option. |
-type=hinfo | displays hardware-related information about the host. It provides details about the operating system and hardware platform |
-type=mx | Lookup for an mx record MX (Mail Exchange) maps a domain name to a list of mail exchange servers for that domain. The MX record says that all the mails sent to “google.com” should be routed to the Mail server in that domain. |
-type=ns | Lookup for an ns record NS (Name Server) record maps a domain name to a list of DNS servers authoritative for that domain. It will output the name serves which are associated with the given domain. |
-type=ptr | used in reverse DNS lookups. It retrieves the Pointer (PTR) records, which map IP addresses to domain names. |
-type=soa | Lookup for a soa record SOA record (start of authority), provides the authoritative information about the domain, the e-mail address of the domain admin, the domain serial number, etc… |
Examples of Some Most Command Options of nslookup in Linux
Performing a basic DNS lookup
Syntax:
nslookup example.com
Example:
nslookup google.com
nslookup followed by the domain name will display the “A Record” (IP Address) of the domain. Use this command to find the address record for a domain. It queries domain name servers and gets the details.

nslookup google.com
Performing a reverse DNS lookup
Syntax:
nslookup [IP Address]
Example:
nslookup 192.168.0.10
You can also do the reverse DNS look-up by providing the IP Address as an argument to nslookup.

nslookup 192.168.0.10
Using `-type=any` option
Syntax:
nslookup -type=any google.com
Lookup for any record We can also view all the available DNS records using the -type=any option.

nslookup -type=any google.com
Using `-type=soa` option
Syntax:
nslookup -type=soa redhat.com
Lookup for a soa record SOA record (start of authority), provides the authoritative information about the domain, the e-mail address of the domain admin, the domain serial number, etc…

nslookup -type=soa redhat.com
Using `-type=ns` option
Syntax:
nslookup -type=ns google.com
Lookup for an ns record. NS (Name Server) record maps a domain name to a list of DNS servers authoritative for that domain. It will output the name serves which are associated with the given domain.

nslookup -type=ns google.com
Using `-type=a` option
Syntax:
nslookup -type=a google.com
Lookup for a record. We can also view all the available DNS records for a particular record using the -type=a option.

nslookup -type=a google.com
Using `-type=mx` option
Syntax:
nslookup -type=mx google.com
Lookup for an mx record. MX (Mail Exchange) maps a domain name to a list of mail exchange servers for that domain. The MX record says that all the mails sent to “google.com” should be routed to the Mail server in that domain.
.jpg)
nslookup -type=mx google.com
Using `-type=txt` option
Syntax:
nslookup -type=txt google.com
Lookup for a txt record. TXT records are useful for multiple types of records like DKIM, SPF, etc. You can find all TXT records configured for any domain using the command below.

nslookup -type=txt google.com
Nslookup Command in Linux – FAQs
What is nslookup command used for?
The `nslookup` command is a network administration tool used for querying the Domain Name System (DNS) to obtain domain name or IP address mapping information. It’s commonly used to troubleshoot DNS-related issues, check DNS records, and diagnose network problems.
How do I use nslookup to find the IP address of a domain?
To find the IP address associated with a domain using `nslookup`, simply type `nslookup domain_name` in your terminal or command prompt, replacing “domain_name” with the actual domain you want to look up. The command will return the corresponding IP address(es) for that domain.
What are the common options or parameters used with nslookup?
Some common options or parameters used with `nslookup` include:
- -query=type: Specify the type of DNS record to query (e.g., A, MX, NS).
- -server=server: Specify the DNS server to use for the query.
- -timeout=seconds: Set the timeout for the query.
- -debug: Enable debug mode to display detailed information.
- -help or ?: Display a help message with available options.
Why do I sometimes get “Non-authoritative answer” in nslookup results?
When `nslookup` returns a “Non-authoritative answer,” it means the DNS server queried is not the primary authoritative server for the domain in question. Instead, it obtained the information from a cached or secondary server. This is common in recursive DNS setups where servers cache responses for performance reasons.
What should I do if nslookup fails to resolve a domain name?
If `nslookup` fails to resolve a domain name, there are several steps you can take to troubleshoot the issue:
- Check your internet connection and ensure DNS servers are reachable.
- Verify the domain name spelling and try again.
- Check your DNS server settings or try querying a different DNS server.
- Look for any firewall or network configuration issues that might be blocking DNS queries.
- Consider using other tools like dig or host for additional troubleshooting.
Conclusion
In this article we have discussed the `nslookup` command which is a variable tool for querying the DNS server and obtaining information about domain name or IP address mapping. We have studied that it is very useful for troubleshooting DNS-related issues. We have also discussed options like -type=a, -type=any, -type=mx, -type=ns, -type=ptr, and -type=soa. Overall, we can say that by using nslookup information, administrators can gain insights into the DNS infrastructure and resolve DNS-related problems efficiently.