How to use nslookup command on Linux and Windows Operating System
Posted on May 16th, 2022
nslookup stands for Name Server Lookup. It’s a helpful command used to get the information from the DNS Server. It’s a simple tool that allows us to perform DNS Lookup commands on Linux and Windows operating systems. Using nslookup commands, we can send a query to the DNS(Domain Name System) and display all the details like IP Address or MX records for the specific domain. We also use the nslookup commands to troubleshoot DNS-related problems.
We can operate the nslookup command in two modes: interactive and non-interactive. Interactive mode allows us to display all the information like various hosts and domains and print the list of the hosts in the domain. On the other hand, the non-interactive mode will only allow you to request just a name and information about the host or domain. So, here in this article, we will learn how we can use the nslookup commands on both OS.
nslookup tool is available on all the windows versions and Linux-based operating systems. So, we can use it directly without installing any third-party tools. So, let’s understand all the nslookup commands and how they work with all the parameters. But before we start, let’s catch up the current machine information like IP address and Preferred DNS server. We can see all the information in two ways on windows. So, follow the steps that show you how to check current network information.
Method 1: Network Settings – Check IP Address and DNS using network settings on Windows Computer.
Step 1: Right-Click on the Network icon from the desktop and click on properties, as you can see in the image below.
Step 2: Now, Click on the second option available, “Change adapter settings,” on the left side of the screen. You can see the image below if you cannot find the options.
Step 3: Now, you may have a list of adapters available on your computer on the next screen. Here, find the currently-using adapter and double-click on it.
Step 4: A popup box will appear on the screen after double-clicking. Click on the Details button to see all the information, as you can see in the below image.
Step 5: You can see a dialogue box below the image with all the network information. You can find your current IP Address, DHCP, and DNS information in this box.
Here, in this tutorial, we learn how to check the Current network information using network settings on windows. If you find this method difficult, another simple way is explained below.
Method 2: CMD – Check IP Address and DNS information using CMD on a windows computer.
Step 1: Open CMD(Command Prompt). Press the Windows key and search CMD, then press Enter.
Step 2: Copy and paste the following command or type ipconfig/all in CMD. Then press enter, as you can see in the image below.
Step 3: Find your currently using network device from the list. So, you can find all the required information below that network device, as you can see below.
Now, let’s understand how to run the DNS query using the nslookup tool. As we discussed, we have two different modes available. Let’s understand one by one and run the commands.
nslookup : non-interactive mode
Open CMD(Command Prompt). You can press the Windows key, search for CMD, and press Enter. Then run the following command, as you can see below.
Nslookup (Domain Name)
Example: nslookup interserver.net
In the above example, We use the nslookup command to request the IP address of the interserver.net domain. We need to type nslookup and then domain name just as an example. This command sends the query to the DNS server, returning the IP address that matches this domain. In this case, it returns the IP address of interserver.net, which is 192.168.54.48. The response indicates that the DNS server is available and working correctly.
In the above exanoke, you can see that after the IP address, a Non-authoritative answer: is mentioned. It simply means that the responded server which answered the query is not the owner of this domain name. So, the nslookup command used a different DNS server to perform the query called a recursive query. We have two types of modes, recursive and non-recursive. To complete the requested DNS lookup query, the server searches several related domains and searches for the required domain’s information. While in non-recursive mode, it will send the exact information or no information.
But if you receive a response like “server:dns1.contoso.com, Address: xx.xx.xx.xx “and an error like “dna1.contoso.com can’t find interserver.net: non-existent domain”, it means your DNS server is not available or not responding. You may also receive a request timed out error. You can also assume that there are no entries available for this domain name on the DNS server, just like the below example.
In this case, check your internet connection and make sure that you entered correct and specific domain details. It may resolve the issue.
We can easily enable and disable recursive mode by using simple commands. Default settings for recurse mode are turned on for DNS queries. Use the following commands to enable or disable the recurse modes.
Now, as we learn in non-interactive mode, how easily we can use nslookup commands in windows. But before turning to interactive mode, there are some points which we have to learn about the interactive mode.
Firstly, whenever you add parameters with the nslookup command, it will display results according to parameters. For example, suppose you want to access the authorised DNS server by some specific address. Then you can use the below command as an example. It shows how we can access the authorised DNS server by the address, and it is used as a parameter directly.
nslookup theitbros.com ns1.theitbros.com
Nslookup with parameters
Here is a tip, all the nslookup commands are case sensitive. And when you only use the nslookup command or without any parameters. It allows us to use interactive mode with all the default command lists. Let’s learn how we can use interactive mode.
nslookup : interactive mode
The interactive mode comes with a list of commands directory. So, how can we see the list? The easiest way to catch the command list is to enter interactive mode. Just use the nslookup command without any parameters. And you will enter in interactive mode. Then you will see an arrow and ask for a command that will follow and display the information. To display the command list, type help, as you can see in the example below.
Entering Interactive mode and Help
If you want to exit from interactive mode, type “exit” and press enter. Windows will turn off the interactive mode.
Now, we can use these commands and combinations from specific results. Here is another example, we can find detailed information like all the DNS servers responsible for particular domains. Try the below example, with other domains as b7you can see in the below example.
The query for interserver Responsible Server List.
Now, you can use these command lists as per your requirement. You can combine one or more commands to create a query. Here are some examples to better understand how the combinations work. The first example shows the Start of Authority or SOA record. This record has information about the domain zone, administrator’s address, serial numbers, etc. Follow the command, copy it to cms, or choose any other domain with this example.
nslookup -type=soa interserver.net
Command and SOA
Upon command shows, the information like primary server name, refresh, serial, expire and default TTL time, as you can see on the example.
Another example of nslookup commands and combinations is, Suppose you want additional information that contains headers of client DNS requests and server responses. In this case, use these commands to display the DNS information, and you can catch the details just as in the example below.
Set Debug and Results
Here, we just learned how we could use nslookup commands on windows. So, next, let’s understand how we can use the nslookup command on the Linux environment.
The nslookup command will work the same as Windows, and all the commands will also work on Linux in the same way. The only difference between both ecosystems is that you have to enter different commands instead of help. As we learn upon tutorial, we have a help command on windows to catch all the command lists. But on the Linux ecosystem, there’s another command. Firstly we will discuss the non-interactive mode and then the interactive mode. Let’s start the tutorial.
nslookup : non-interactive mode
To use nslookup in non-interactive mode or with parameters, type nslookup and then the domain name you want to display the information. As we discussed, the nslookup command will work the same on both operating systems. So, as you can see in the below example, we just used nslookup with the interserver.net domain name on the Linux terminal. The results display in a manner of the Linux ecosystem.
nslookup domain name(interserver.net)
As discussed, we have another command for having help for the nslookup command on the Linux ecosystem. And it’s based on the Linux help system. We have to type man before the command, Just like the example below. It will display the full description for any command. You can search for any command you want with man, and it gives you a full description, just like the example below.
Help for nslookup Command on Linux
Just press “q” to get out from the help page.
nslookup : interactive mode
The nslookup interactive mode will also work the same as windows. We need to type only the command as “nslookup” and press enter. You will enter in interactive mode just like windows. Here you can see the example of the interactive mode in the example below.
All the commands we learn on Windows will work on Linux as well. You can combine one or more commands in the non-interactive mode for accurate results. The ecosystem’s benefits are also available, like help and man commands. You can learn more commands and gather more information about domains and DNS servers.
We had to learn the nslookup command and use some examples to display DNS information for domains. We also learned that the nslookup command works on Windows and Linux environments. But, we have only one difference between both environments: a help directory command. We use the help command in interactive mode on windows, while the man commands on Linux os. Now, you can combine the commands as given on the help command.