How to Use the Nslookup Command

The nslookup command is one of the best ways to find a host’s IP address or domain name. It’s a command line tool; most basic operating systems provide their own nslookup tool. The nslookup tool can be accessed through a system’s command center. In this article, learn what the command is, how it works, and how to use it in your operating system.

What is nslookup?

The name nslookup stands for "name server lookup." Name server lookup is a network administration command-line tool that queries the domain name system (DNS) to obtain domain names or IP addresses.

The command retrieves information about IP addresses that correspond to a web host or hostname associated with a specific IP address through a process called a reverse DNS lookup. In other words, users use nslookup to search up DNS records. The name server lookup does exactly what DNS resolvers do: resolves user's queries. The tool is available in many computer operating systems and allows it self to be used in the command-line interface of the operating system.

Windows users can start the nslookup command by using the command prompt, while Unix users can do it through the Terminal window.

With the name server lookup command, you can get fundamental DNS information much quicker. You can easily check if a domain name is resolving correctly to an IP address, troubleshoot network issues, and verify the correctness of your DNS configuration.

How the nslookup command works

The nslookup command works to retrieve information directly from name servers in your DNS service. It operates in two different modes: noninteractive mode and interactive mode.

Interactive mode works better for more advanced users. The parameters for lookup are added separately so they can be sent by users. The command queries name servers for information on hosts and domains.

Noninteractive mode enters the name server lookup command and the desired parameters, making it easier for beginners getting to know the commands. With noninteractive mode, the nslookup tool inspects the address entries in your DNS servers cache. It retrieves the current DNS server you’re using, the domain URL, and the IPv4 and IPv6 addresses.

Nslookup

How to access the nslookup command

Learning how to use the nslookup command is simple. The command is accessible on almost every software system through the command center and helps perform various DNS-related tasks, including DNS and reverse DNS searches. To find the command center on your computer and nslookup an IP address, follow the instructions below for Microsoft, Apple, and Linux.

Nslookup command on Microsoft

Microsoft computer users have several ways to access the command prompt and input the name server lookup command in Windows.

Open the Windows start menu and search command prompt in the search bar. It will pop up with a shortcut for access.

  1. Open the Run box by pressing Windows+R.
  2. Type cmd into the box that comes up and then hit OK to open command prompt.
  3. If you find yourself running commands often, create a Desktop shortcut by right-clicking an empty spot on the Desktop to pull up the context menu. Select New and Shortcut, then type exe into the Shortcut box. Hit Next and name the shortcut, and you will have an easy way to access command prompt from the Desktop.

Nslookup command on Apple

For Apple Macbook users, the name server lookup command is executed through the Terminal app.

  1. Go to the Finder in the top left corner of your device.
  2. Open the Applications
  3. Click on the Utilities folder, then find Terminal.
  4. Enter the command nslookup and the IP address you’re searching for.

Nslookup command on Linux

For IBM Linux users, the Linux name server lookup command can be executed through its terminal window.

  1. Press Ctrl+Alt+T in Ubuntu.
  2. Hit Enter.
  3. From here, you can then execute the command by typing in nslookup and the IP address or website you wish to query.

Basic nslookup commands

There are a number of nslookup example commands that can be executed, depending on the information or record types that the user wants. Note that for all of these commands, you must enter the domain you wish to search in place of ‘example.com.’

Search for the A records of a domain

The name server lookup command can ask for the A records of a domain, which reveals all IP addresses related to a particular host. Use the command nslookup example.com.

Search for the NS records of a domain

NS records stand for name server records. The name server reveals which DNS server contains the DNS records for a particular domain; it shows where to go to find a domain’s IP address. Improperly configured NS records result in difficulties loading websites and other issues. Use the command nslookup -type=ns example.com.

Check the SOA records of a domain

SOA stands for Start of Authority. Every domain has a Start of Authority record, which indicates where the domain diverged from a parent domain. Executing this command will also gather zone information. Use the command nslookup -type=soa example.com.

Check MX records

Nslookup can also check mail servers and verify that they are working properly. MX records stands for Mail Exchange records, which are DNS records necessary for delivering mail to your address. Use the command nslookup -query=mx example.com.

Find all the available DNS records for a domain

The command works to locate domain name system (DNS) records like a DNS lookup, too. Use the command nslookup -type=any example.com. To check a specific DNS server, use the command nslookup example.com ns1.nsexample.com.

Do a reverse DNS lookup

You can also check if an IP address is related to a specific domain with the name server lookup command in a reverse DNS lookup. Use the command nslookup 10.20.30.40.

Set the query type

To set the query type to a specific type, such as AAAA (IPv6), use the following command: nslookup -type=aaaa example.com.

View pointer records

The command helps access pointer records, also known as PTR records. PTR records are used to map an IP address to its corresponding domain name, which is the opposite of what A records do. Use this command to display only the PTR record for an IP address: nslookup -type=ptr1.0.168.192.in-addr.arpa.

Frequently asked questions

Can I use dig instead of nslookup?

Yes, you can use the "dig" command to look up DNS records. Both commands perform similar functions but have different syntax and output formats.

What's the difference between ping and nslookup commands?

While both tools are related to networking, they have different functions. The ping command tests network connectivity and measures network latency. The name server lookup command, however, queries DNS servers to obtain hostname or IP address mapping information.

What's the difference between nslookup and DNS lookup?

No difference exists between these two tools, as the name server lookup is a command-line tool used for retrieving DNS records.

Is nslookup a DNS tool?

Yes. It's a command-line tool used to check all the DNS records of a domain.