How can we help you today?
Business Consultants Let our experts help you find the right solution for your unique needs.
855-834-8495 Hours: M-F 8am-11pm ET
Hours: 24/7
Product Support We’re here to help with setup, technical questions, and more.
Hours: 24/7

Type above and press Enter to search. Press Esc to cancel.

Home Blog Site Security and Management​ What Is nslookup and How Does it Work? 
A woman facing at a computer screen, showing what an nslookup is
,

What Is nslookup and How Does it Work? 

Key takeaways 

  • nslookup queries Domain Name System (DNS) records and troubleshoot website issues. 
  • nslookup can verify domain settings, perform reverse DNS lookups, and check specific records like A, MX, CNAME, and TXT. 
  • Understanding nslookup enhances domain management and helps identify DNS issues so you can defend your site against threats like cache poisoning. 

Did it ever happen where your website suddenly becomes unreachable, emails stop working, or you suspect a security threat? This is exactly where you’ll need nslookup. It’s a tool for diagnosing and troubleshooting DNS-related problems. 

In this article, we’ll explore everything you need to know about nslookup and how you can use it. 

What is nslookup? 

nslookup (short for Name Server Lookup) is a command-line tool that helps you query the DNS to find domain information. It retrieves DNS records associated with a domain name, such as IP addresses, mail server details, and other critical domain-related information. 

Think of it like a phonebook: Just as you look up a person’s name to find their phone number, nslookup allows you to enter a domain name and retrieve its corresponding IP address or other DNS records. 

When to use nslookup?   

nslookup is a vital tool for various use cases, including: 

  • Troubleshooting DNS issues 
  • Investigating suspicious domains 
  • Defending against cache poisoning 

Troubleshooting DNS issues 

If a domain’s IP address has changed but requests aren’t resolving properly, nslookup can help pinpoint the issue and confirm DNS propagation. 

Investigating suspicious domains 

Cybercriminals often create domain names that mimic legitimate websites. nslookup can help verify whether a domain is authentic by checking its DNS records. 

Defending against cache poisoning 

Cache poisoning is a cyberattack in which malicious DNS data is inserted into DNS caches. Administrators can identify and mitigate these threats by comparing known legitimate records with nslookup queries. 

How to use nslookup: Step-by-step guide 

nslookup is built into most operating systems, including Windows, macOS, and Linux. Here’s how you can use it, step by step:   

Step 1. Open the Command Prompt or Terminal   

  • Windows users. Press Win + R, type cmd, and hit Enter.  
  • macOS users. Open Terminal from the Applications folder or search for it in Spotlight (Cmd + Space → type “Terminal”).   
  • Linux users. Open the Terminal from your applications menu or press Ctrl + Alt + T. 

You’ll need to use these programs to run nslookup commands.  

Step 2: Run a basic nslookup query   

To retrieve the IP address of a website, type the following command and press Enter:   

nslookup example.com 

Note: Replace example.com with the domain name you want to query.   

Expected output:   

Server:  dns-server-address   
Server:  dns-server-address   
Address:  xxx.xxx.xxx.xxx   
Non-authoritative answer:   
Name:    example.com   
Address:  192.168.1.1   

The output will display the DNS server responding to your query and the IP address of the domain you searched for.  

Step 3: Find mail server information 

If you want to check the mail servers associated with a domain, use:   

nslookup -type=MX example.com   

This will return a list of mail exchange (MX) records, which indicates the mail servers that handle emails for the domain.   

Step 4: Retrieve a specific DNS record   

Different DNS records serve different purposes. You can use nslookup to query specific records like: 

  • A record (IPv4 address) 
  • MX record (Mail exchange record) 
  • CNAME record (Alias record) 
  • TXT record (Text record) 

Here’s how you can retrieve specific records: 

A record (IPv4 address)   

The A record maps a domain name to an IPv4 address. It tells the DNS system which IP address corresponds to a given domain. 

nslookup -type=A example.com  

MX record (Mail exchange record)   

The MX record specifies mail servers responsible for receiving emails for a domain. It helps route emails to the correct server.   

nslookup -type=MX example.com 

CNAME record (Alias record)   

The CNAME record maps one domain to another, allowing multiple domain names to point to the same website.  

nslookup -type=CNAME example.com   

TXT record (Text record)   

The TXT record stores arbitrary text-based information, often used for security purposes, such as SPF and DKIM authentication.   

nslookup -type=TXT example.com   

Step 5: Perform a reverse DNS lookup   

If you have an IP address and want to find out which domain it belongs to, use:   

nslookup 192.168.1.1 

This command will return the associated domain name if one exists.   

Step 6: Query a Different DNS Server   

If you suspect an issue with your current DNS server, you can check the results from a different one, such as Google’s public DNS at 8.8.8.8, to see if the problem lies with your server. This is especially helpful for troubleshooting discrepancies in DNS responses.  

Use the following command:  

nslookup example.com 8.8.8.8   

By doing this, you can compare the results from different DNS servers to identify any inconsistencies or issues with your current DNS configuration. 

Common nslookup options 

Here are common options you can use when requesting different domain information: 

Options Purpose 
-debug To retrieve debugging information. 
-timeout=[seconds] To specify the time allowed for the server to respond. 
-type=a To view DNS A records. 
-type=CNAME To find Canonical Name (CNAME) records, showing if a hostname is an alias for another domain. 
-type=TXT To check Text (TXT) DNS records for email authentication or domain verification. 
-type=any To view all available records. 
-type=hinfo To view hardware-related information of the host. 
-type=mx To view Mail Exchange server information. 
-type=ns To view Name Server records. 
-type=ptr To view Pointer records. 
-type=soa To retrieve Start of Authority records. 

You can use nslookup in two modes: interactive and non-interactive

Interactive mode lets you query multiple servers. To start the mode, type nslookup only. Then, type in the domain name that you want to retrieve information from. You can also specify an option in a separate line before the query. This way you can customize what type of information you want to get. 

Non-interactive mode, on the other hand, lets you query one server at a time. To initiate a non-interactive mode, type: 

nslookup [options] [domain-name] 

Start troubleshooting DNS issues with nslookup  

nslookup is a powerful tool for diagnosing DNS issues, retrieving domain records, and troubleshooting website accessibility problems. Mastering nslookup can help you gain better control over domain management and security.   

While constantly checking DNS records with nslookup is useful, you don’t have to always feel anxious when these issues will suddenly pop up. 

Take precautionary measures before problems arise with Network Solutions’ powerful security tools to protect your site and domain from malware, hackers, and viruses.   

Get started today! 

Frequently asked questions 

What is the difference between nslookup and DIG?   

Both nslookup and DIG are command-line tools used to query DNS records. Even though nslookup is widely available across various operating systems and is user-friendly, network administrators often prefer DIG (Domain Information Groper) for its detailed output and advanced features. DIG is typically available on Unix-like systems and provides more granular control over DNS queries. 

Is it legal to use nslookup?   

Yes, using nslookup is legal. Just make sure to use it ethically and follow any relevant terms of service. However, it’s important to use it ethically and avoid violating any terms of service or accessing DNS records without proper authorization. Always follow best practices and respect privacy when querying domain information. 

Read more from this author

Get Your Site Online—Fast and Hassle-Free

Skip to Section

Get Your Site Online—Fast and Hassle-Free

Short on time? Leave it to our expert designers.

  • Custom website design & copy
  • Your own in-house design team
  • Content with SEO in mind
  • Easy-to-reach support

Speak with an expert today!