What Is nslookup Command and How to Use It?

Learn how to troubleshoot network issues like a pro with our comprehensive guide to using the nslookup command. Unlock the power of this essential tool and take your network troubleshooting skills to the next level. Perfect for content creators and IT professionals alike.

Updated: 16 Apr, 24 by Susith Nonis 24 Min

List of content you will read in this article:

NSLookup (short for Name Server Lookup) is a command-line tool commonly used to query the Domain Name System (DNS) to obtain information about domain names, IP addresses, and other DNS records. It is available on most operating systems, including Windows, Linux, and macOS. The NSLookup command is used to diagnose and troubleshoot DNS-related issues and retrieve information about domain names and their associated IP addresses. It sends a query to a DNS server, which returns the requested information to the user.

NSLookup can perform various tasks, including checking the DNS records for a domain, verifying that a DNS server is working correctly, and troubleshooting DNS-related problems. The command also has various options that allow users to customize their queries and obtain more detailed information about DNS records. NSLookup is a powerful tool widely used by system administrators and network engineers to diagnose and resolve DNS-related issues.

NSLookup is a command-line tool that queries the Domain Name System (DNS) to obtain information about domain names, IP addresses, and other DNS records. It allows users to retrieve information such as the IP address of a domain name or the mail server associated with a domain name. NSLookup sends a query to a DNS server and receives a response, which is then displayed to the user. It is a powerful tool for diagnosing and troubleshooting DNS-related issues and is available on most operating systems, including Windows, Linux, and macOS. Overall, NSLookup is a fundamental tool for network administrators and system engineers working with DNS systems.

The nslookup command is a network administration tool used in operating systems like Windows, Linux, and macOS command-line interface. It is used to query the Domain Name System (DNS) to obtain information about domain names, IP addresses, and other DNS records.

The nslookup command operates in two modes: interactive and non-interactive. To activate the interactive mode, simply enter the command:

Nslookup

This prompts you to execute multiple server queries.

For instance, typing a domain name like:

www.google.com

will provide information about it.

Once nslookup displays the information, it presents another prompt.

In interactive mode, provide a choice on an additional line before the query is executed. Begin the selection with set:

set [option]

To exit interactive mode, type:

exit

Non-interactive mode allows you to issue single queries. The syntax is:

nslookup [options] [domain-name]

Both the command and the query are written in the same line.

Here's how to use the nslookup command:

  • Open a command prompt/terminal window on your computer.
  • Type nslookup followed by the domain name or IP address you want to look up. For example:

nslookup example.com

  • Press Enter. The command will retrieve and display the DNS information associated with the domain name or IP address you entered.

You can also use nslookup to query a specific DNS server by specifying its IP address. For example:

nslookup example.com 8.8.8.8

This will retrieve the DNS information, for example.com, from the DNS server at IP address 8.8.8.8.

The nslookup command can be useful for troubleshooting network connectivity issues, verifying DNS configurations, and performing various other network-related tasks.

nslookup Options

Here we provide a table presenting nslookup options which provide flexibility and control over nslookup queries:

Option

Description

-d    

Enable debugging output                     

-query

Specify query type (e.g., A, NS, MX, PTR)  

-port 

Specify port number to use for queries      

-timeout

Set query timeout in seconds              

-class

Specify query class (e.g., IN, CH)          

-type

Same as -query option (deprecated)          

-root 

Set root server to query                    

-server

Specify DNS server to use                   

-recurse

Enable or disable recursion                 

-retry

Set number of retries for a query           

-domain

Set default domain name to append to queries

-srchlist

Set domain search list                     

-msxfr

Request zone transfer from Microsoft DNS Server

-defname

Append default domain name to queries      

-tkey

Specify TSIG key for TSIG-secured queries   

-tsig

Specify TSIG algorithm and key for TSIG-secured queries

-l    

Enable or disable strict label checking     

-i    

Use IP address for reverse lookup           

-h    

Display help information                    

You ought to be advised that the "nslookup" command has been discontinued in many operating systems and has been displaced by other appliances such as "dig", or that "nslookup" might have been replaced by the newer "nslookup".

If you're running a Windows operating system, the "nslookup" tool should be installed by default. To open a command prompt, hit the Windows key + R, type "cmd" in the Run dialog, and then press Enter. Then you can use the "nslookup" command in the command prompt.

If you have a Linux-based machine, you are able to install the "dnsutils" package, which contains the "nslookup" command. The setting up procedure may differ based on your Linux distribution. For instance, on Ubuntu or Debian, you can open a terminal and enter the following command to install it:

sudo apt-get update

sudo apt-get install dnsutils

For other distributions, you can use their respective package managers, such as "yum" for CentOS or "dnf" for Fedora, to install the "dnsutils" package.

Note: Depending on your operating system and version, there may be several tools or commands available for performing DNS queries. For example, "dig" is a popular command-line tool for performing DNS queries that is accessible on a variety of operating systems.

The nslookup command is used to query the Domain Name System (DNS) to obtain information about domain names, IP addresses, and other DNS records. Here are some common uses of the nslookup command:

Check DNS records

You can use nslookup to retrieve DNS records for a particular domain name, such as its IP address, mail server records, or nameserver records. To check DNS records with the nslookup command, follow these steps:

Open a command prompt/terminal window on your computer.

Type nslookup followed by the domain name you want to look up. For example:

nslookup example.com

Press Enter. The command will retrieve and display the DNS information associated with the domain name you entered.

Here's an example of the output you might see:

makefile

Server:  UnKnown

Address:  192.168.1.1

Name:    example.com

Addresses:  93.184.216.34

This output shows the DNS server used for the query and the IP address(es) associated with the domain name.

To query a specific DNS record, you can use the following syntax:

python

nslookup -type=<record-type> example.com

Replace <record-type> with the type of record you want to query, such as MX for mail server records or NS for nameserver records. For example:

python

Copy code

nslookup -type=MX example.com

This will retrieve the mail server records, for example.com.

If you want to query a specific DNS server, you can use the following syntax:

php

nslookup example.com <dns-server-ip>

Replace <dns-server-ip> with the IP address of the DNS server you want to query. For example:

nslookup example.com 8.8.8.8

This will retrieve the DNS information, for example.com, from the DNS server at IP address 8.8.8.8.

Using the nslookup command to check DNS records, you can verify that domain names are resolving to the correct IP addresses, mail server records are configured correctly, and nameserver records are set up properly.

Troubleshoot network connectivity issues

 If you are experiencing network connectivity issues, you can use nslookup to check whether a domain name resolves to the correct IP address or to identify DNS servers that are not responding. To troubleshoot network connectivity issues using the nslookup command, follow these steps:

Open a command prompt/terminal window on your computer.

Type nslookup followed by the domain name you are having issues with. For example:

nslookup example.com

Press Enter. If the command returns the correct IP address for the domain name, the DNS resolution is working correctly. If not, there may be a DNS configuration issue.

If the DNS resolution is working correctly, but you are still experiencing network connectivity issues, try pinging the IP address returned by the nslookup command. For example:

ping 93.184.216.34

This will send a ping request to the IP address 93.184.216.34, associated with the domain name example.com.

If the ping command fails or times out, there may be a network connectivity issue, such as a firewall blocking the connection or a routing issue. You can try pinging other IP addresses to see if the issue is isolated to a particular destination.

Suppose the ping command succeeds, but you are still experiencing network connectivity issues. In that case, you can try querying other DNS servers using the nslookup command to see if there is a problem with your default DNS server. For example:

nslookup example.com 8.8.8.8

This will retrieve the DNS information, for example.com, from the Google DNS server at IP address 8.8.8.8.

Using the nslookup command to troubleshoot network connectivity issues, you can identify DNS configuration issues, network connectivity problems, and routing issues that may be causing the problem.

Verify DNS configurations

 nslookup can help you verify that your DNS server configurations are correct by confirming that the DNS records for your domain names are being served correctly. To verify DNS configurations using the nslookup command, follow these steps:

Open a command prompt/terminal window on your computer.

Type nslookup followed by the domain name you want to verify. For example:

nslookup example.com

Press Enter. The command will retrieve and display the DNS information associated with the domain name you entered, including the IP address, mail server records, and nameserver records.

Verify that the DNS information displayed matches the expected configuration for your domain. For example, if you use a particular mail server for your domain, check that the mail server record displayed by nslookup matches the expected value.

If you have changed your DNS configuration, you can use the nslookup command to verify that the changes have been propagated to DNS servers worldwide. To do this, you can query a public DNS server, such as Google DNS or OpenDNS, using the following syntax:

nslookup example.com 8.8.8.8

This will retrieve the DNS information, for example.com, from the Google DNS server at IP address 8.8.8.8. If the information returned by the public DNS server matches your expected configuration, the changes have been propagated.

Using the nslookup command to verify DNS configurations, you can ensure that your DNS records are set up correctly and that changes to your DNS configuration have been propagated correctly. This can help prevent issues such as mail delivery failures or website downtime.

Test DNS servers

You can test the performance of different DNS servers by querying them with nslookup. This can help you identify the fastest DNS server for your location. To test DNS servers using the nslookup command, follow these steps:

Open a command prompt/terminal window on your computer.

Type nslookup followed by the domain name you want to test and the IP address of the DNS server you want to test. For example:

nslookup example.com 8.8.8.8

This will retrieve the DNS information, for example.com, from the Google DNS server at IP address 8.8.8.8.

Press Enter. The command will retrieve and display the DNS information associated with the domain name you entered using the specified DNS server.

Verify that the DNS information displayed matches the expected configuration for your domain. If the information matches, the DNS server is working correctly. If not, there may be a problem with the DNS server configuration or the DNS resolution process.

You can also use the nslookup command to test the response time of a DNS server, which can help identify slow or unreliable DNS servers. To do this, use the following syntax:

lua

nslookup -type=NS -debug example.com <dns-server-ip>

Replace <dns-server-ip> with the IP address of the DNS server you want to test. This will retrieve the nameserver records, for example.com, from the DNS server you specified and display debugs information, including the server's response time.

By using the nslookup command to test DNS servers, you can identify problems with DNS server configuration or performance and ensure that your DNS servers are working correctly and providing accurate information.

Debugging network applications

Developers can use nslookup to debug network applications by verifying that DNS queries are being sent and received correctly. You can use the nslookup command to debug network applications by tracing the DNS lookup process for a domain name. This can help you identify problems with DNS resolution that may be affecting the performance of your application. To do this, follow these steps:

Open a command prompt/terminal window on your computer.

Type nslookup followed by the domain name you want to trace. For example:

nslookup example.com

Press Enter. The command will retrieve and display the DNS information associated with the domain name you entered, including the IP address, mail server records, and nameserver records.

If the initial DNS lookup does not return the expected information, you can use the -debug option to enable debugging information for the nslookup command. To do this, type the following command:

lua

nslookup -debug example.com

Press Enter. The command will retrieve and display detailed debugging information for the DNS lookup process, including the queries and responses between the client and the server. This can help you identify problems with DNS resolution that may be affecting the performance of your application.

Using the nslookup command to debug network applications, you can identify problems with DNS resolution that may be causing performance issues or other problems with your application. This can help you troubleshoot and resolve these issues more quickly and effectively.

If the 'nslookup' function is unavailable or you are seeking for alternatives, you can use other command-line tools or web services to perform DNS lookups and troubleshooting. We are going explore several alternatives:

1- dig (Domain Information Groper): dig is a sophisticated DNS lookup application that is available on most Unix-like operating systems. It provides more detailed information than 'nslookup' and is favored by many system administrators.

Example usage:

     dig example.com

2- host: On Unix-like computers, you can also use the 'host' command to look up DNS. It's simpler than 'dig' yet still yields meaningful results.

Example usage:

     host example.com

3- ping: While primarily used for testing network connectivity, the `ping` command can also resolve hostnames to IP addresses.

Example usage:

     ping example.com

4- Online DNS lookup tools: If you're unwilling to employ command-line tools, there are multiple online DNS search services accessible. These services let you to do DNS lookups right from your web browser. Examples are MXToolbox, DNSstuff, WhatIsMyDNS, and Network-Tools.com.

5- GUI DNS utilities: There are various graphical DNS programs accessible for different operating systems. Such programs often offer a user-friendly interface for DNS lookups. Examples are DNSQuerySniffer for Windows and DnsTool for macOS.

Each of these choices has a unique combination of features and benefits, allowing you to pick the option that best meets your requirements and tastes.

Both 'nslookup' and 'ping' are command-line applications often used for network troubleshooting, however they perform different functions.

1- nslookup (Name Server Lookup)

  • Purpose: nslookup is primarily used for querying DNS (Domain Name System) servers to obtain domain name or IP address information.
  • Functionality: It allows you to perform various types of DNS queries, such as looking up IP addresses associated with domain names (forward lookup), finding domain names associated with IP addresses (reverse lookup), querying specific types of DNS records (e.g., MX, NS, SOA), and specifying DNS servers to use.
  • Example Usage: nslookup example.com

2- ping

  • Purpose: ping is used to test the reachability of a host on a network and measure the round-trip time for packets sent from your computer to the target host.
  • Functionality: It sends ICMP (Internet Control Message Protocol) Echo Request packets to the target host and waits for ICMP Echo Reply packets. This helps determine whether the target host is reachable and calculates the latency (round-trip time) between your computer and the target host.
  • Example Usage: ping example.com

nslookup is used for DNS-related operations, whereas whois is used to obtain domain registration information. Depending on your requirements, you can utilize one or both of these programs for network-related activities. Here are the main distinctions between them:

  • Purpose: nslookup is used for DNS-related tasks such as resolving domain names to IP addresses and vice versa, while whois is used for querying domain registration information.
  • Output: nslookup typically provides DNS-related information such as IP addresses, domain names, and DNS server details, while whois provides domain registration details such as registrar information, registration dates, and contact information.
  • Protocol: nslookup uses the DNS protocol to communicate with DNS servers, while whois uses the WHOIS protocol to query WHOIS databases.
  • Usage: nslookup is more focused on DNS troubleshooting and configuration, while whois is used for obtaining information about domain registrations and ownership.

We provided a table that outlines the essential characteristics, aims, functionalities, protocols, and example usages of WHOIS, Nslookup, and Ping, allowing for a clear comparison of these network tools:

Feature       

WHOIS                                           

Nslookup                                        

Ping                                             

Purpose      

Query domain registration information            

Query DNS (Domain Name System) information      

Test network connectivity and measure latency   

Functionality

Retrieve domain registration details such as registrar information, registration dates, and contact information

Perform DNS queries to obtain domain name or IP address information, including forward and reverse lookups, querying specific types of DNS records, and specifying DNS servers to use

Send ICMP Echo Request packets to target hosts and measure round-trip time for packets sent and received

Protocol     

WHOIS protocol                                  

DNS protocol                                    

ICMP protocol                                   

Usage        

Helps determine ownership and registration status of domain names

Used for DNS troubleshooting and configuration, including resolving domain names to IP addresses, querying DNS records, and specifying DNS servers

Used for basic network connectivity testing and latency measurement

In summary, the nslookup command is a versatile network administration tool that can be used for various DNS-related tasks, from troubleshooting network connectivity issues to testing DNS server performance. In conclusion, the nslookup command is a powerful tool for troubleshooting and verifying DNS configurations, testing DNS servers, and debugging network applications. Using the various options and syntax available with the nslookup command, you can retrieve detailed information about DNS records, test the performance and reliability of DNS servers, and identify and resolve problems with DNS resolution that may be affecting the performance or availability of your applications. Whether you are a network administrator, developer, or system administrator, understanding how to use the nslookup command can help you ensure your network and applications' optimal performance and reliability.

To use nslookup, open a command prompt or terminal and type `nslookup` followed by the domain name or IP address you want to query. Press Enter to execute the command.

The command to check DNS is `nslookup` (Name Server Lookup). By default, running `nslookup` without any arguments enters interactive mode, allowing you to perform multiple DNS queries from the command prompt.

The nslookup tool is used to query DNS (Domain Name System) servers to obtain information about domain names or IP addresses. It helps users perform various DNS-related tasks, including resolving domain names to IP addresses (forward lookup), finding domain names associated with IP addresses (reverse lookup), querying specific types of DNS records (e.g., MX, NS, SOA), and specifying DNS servers to use.

To find your hostname using nslookup, open a command prompt or terminal and type `nslookup` followed by your IP address. Press Enter to execute the command. Nslookup will perform a reverse DNS lookup and display the corresponding hostname associated with the IP address.

Susith Nonis

Susith Nonis

I'm fascinated by the IT world and how the 1's and 0's work. While I venture into the world of Technology, I try to share what I know in the simplest way with you. Not a fan of coffee, a travel addict, and a self-accredited 'master chef'.