The nslookup command is a powerful network administration tool used for querying the Domain Name System (DNS) to obtain domain-related information. Whether you’re troubleshooting DNS issues on a VPS hosting plan or managing domains on a dedicated server, understanding how to use nslookup effectively can help diagnose and resolve network-related problems.

What is the nslookup Command?

The nslookup (Name Server Lookup) command is used to query DNS records, retrieve IP addresses of a domain, and check various DNS configurations. It is available by default on both Windows and Linux operating systems.

Why Use the nslookup Command?

  • Troubleshoot DNS resolution issues.
  • Retrieve IP addresses of domain names.
  • Verify DNS record configurations.
  • Check mail server (MX) records for a domain.
  • Find authoritative name servers for a domain.

How to Use nslookup on Windows

1. Open the Command Prompt

To use nslookup on Windows, open the Command Prompt by pressing:

Win + R -> type 'cmd' -> Enter

Alternatively, you can search for “Command Prompt” in the Start menu.

2. Query a Domain’s IP Address

To find the IP address of a website, use the following command:

nslookup example.com

3. Get MX Records (Mail Exchange) for a Domain

To retrieve the mail server records (MX records) for a domain:

nslookup -query=mx example.com

4. Find the Name Server (NS) Records

To check which name servers are responsible for a domain:

nslookup -query=ns example.com

5. Perform a Reverse Lookup (Find Domain from IP Address)

If you have an IP address and need to determine its associated domain:

nslookup 192.168.1.1

How to Use nslookup on Linux

The nslookup command is also available on Linux and works similarly to Windows.

1. Open the Terminal

To use nslookup on Linux, open a terminal window by pressing:

Ctrl + Alt + T

2. Query a Domain’s IP Address

To look up the IP address of a domain:

nslookup example.com

3. Retrieve MX Records

To find out which mail servers handle email for a domain:

nslookup -query=mx example.com

4. Find Name Servers (NS) for a Domain

To check which name servers are associated with a domain:

nslookup -query=ns example.com

5. Perform Reverse DNS Lookup

If you have an IP address and need to find its associated hostname:

nslookup 192.168.1.1

Advanced nslookup Usage

1. Use a Specific DNS Server

By default, nslookup uses the system-configured DNS server. To query a specific DNS server, use:

nslookup example.com 8.8.8.8

This will use Google’s public DNS (8.8.8.8) to resolve the domain.

2. Enable Interactive Mode

To enter interactive mode, simply type nslookup and press Enter:

nslookup

Then, you can enter multiple queries without exiting the tool.

3. Get All Available DNS Records

To retrieve all available DNS records for a domain:

nslookup -query=any example.com

Conclusion

The nslookup command is an essential tool for diagnosing DNS-related issues and verifying domain configurations. Whether you’re working with VPS hosting or a dedicated server, mastering nslookup can significantly improve your network troubleshooting skills and domain management efficiency.