The nslookup
command is a powerful tool used for querying Domain Name System (DNS) records. It helps troubleshoot network issues, verify domain configurations, and gather essential DNS information. In this article, we’ll explore how nslookup
works and provide examples of its usage.
What is nslookup?
nslookup
(short for “name server lookup”) is a command-line utility available on Windows, macOS, and Linux. It queries DNS servers to obtain domain name or IP address mapping, along with other DNS records such as MX (Mail Exchange), TXT, and NS (Name Server) records.
Basic Syntax
The general syntax of the nslookup
command is:
nslookup [options] [hostname]
Without any arguments, nslookup
enters interactive mode, allowing users to perform multiple queries within a session. Supplying a hostname directly returns its corresponding IP address.
Examples of Using nslookup
1. Basic Domain Name Lookup
To find the IP address of a domain:
nslookup example.com
Output:
Server: 8.8.8.8
Address: 8.8.8.8#53
Non-authoritative answer:
Name: example.com
Address: 93.184.216.34
This shows the DNS server used and the resolved IP address of example.com
.
2. Reverse Lookup (Find Domain from IP Address)
To determine the domain associated with an IP address:
nslookup 93.184.216.34
If the reverse DNS entry exists, the domain name associated with the IP will be displayed.
3. Query a Specific DNS Record Type
You can specify a record type to retrieve specific DNS information.
Get Mail Exchange (MX) Records
nslookup -query=mx gmail.com
Get Name Server (NS) Records
nslookup -query=ns google.com
Get Text (TXT) Records (Often Used for SPF, DKIM, and Domain Verification)
nslookup -query=txt example.com
4. Use a Specific DNS Server
By default, nslookup
queries the DNS server configured on your system. However, you can specify a different DNS server:
nslookup example.com 8.8.8.8
This forces nslookup
to use Google’s public DNS server (8.8.8.8) instead of the default.
5. Interactive Mode
To enter interactive mode, simply type:
nslookup
Then, enter queries interactively. For example:
> server 8.8.8.8 # Change the DNS server
> set type=mx # Set query type to MX
> google.com # Query the MX records of Google
> exit # Exit interactive mode
6. Debugging and Verbose Output
For more detailed responses, enable debugging:
nslookup -debug example.com
This provides additional details about the DNS resolution process, useful for troubleshooting.
Conclusion
The nslookup
command is an essential tool for network administrators and IT professionals. It provides a quick and efficient way to query DNS records, troubleshoot network issues, and verify domain configurations. By mastering nslookup
, you can gain deeper insights into DNS resolution and improve your ability to diagnose connectivity problems.