Table of contents
1.
Introduction
2.
What is nslookup Command?
3.
Syntax of nslookup command
4.
Purpose of the nslookup Command
5.
nslookup Command Options
6.
Examples of nslookup command
6.1.
nslookup [Domain name]
6.2.
nslookup [IP Address]
6.3.
debug
6.4.
timeout
6.5.
type=ns
6.6.
type=mx
6.7.
type=a
6.8.
type=txt
6.9.
type=hinfo
6.10.
type=soa
6.11.
type=any
7.
Frequently Asked Questions
7.1.
What is the full form of nslookup?
7.2.
How do I get the IP address from nslookup?
7.3.
What is the nslookup tool used for?
7.4.
What is nslookup in DNS server?
7.5.
What is nslookup command in Linux?
7.6.
How to use nslookup command in Windows?
8.
Conclusion
Last Updated: Mar 27, 2024
Easy

Nslookup Command in Linux

Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Hello, ninjas! You must have heard about DNS, IP addresses, Linux, etc. In this article, we will study the nslookup command in Linux. Before learning about the nslookup command, you should know what Linux is. 

Linux is basically a set of open-source operating systems based on the Linux kernel. It is an operating system that is free and available to everyone.

Nslookup Command in Linux

Also read, Features of linux operating system

What is nslookup Command?

nslookup command stands for Name Server Lookup. It is a command that queries a DNS(Domain Name System) server and gets information about it. 

  • It is a tool for network administration. 
     
  • It can obtain information such as domain names, IP addresses, mail servers, etc. 
     
  • It can also help in troubleshooting DNS errors.
     

You should be connected to the internet to use this command. Also, you should be familiar with different types of DNS records.

Syntax of nslookup command

The nslookup command is used for querying DNS (Domain Name System) to obtain domain name or IP address information. Its basic syntax is:

nslookup [options] [domain or IP address]

Purpose of the nslookup Command

The nslookup command is a network tool used to find information about domain names and IP addresses. Its main purposes include:

  • DNS Query: It helps you look up IP addresses associated with domain names (forward lookup) and domain names associated with IP addresses (reverse lookup).
     
  • Troubleshooting: It's useful for diagnosing network issues. If a website or server isn't working, you can use nslookup to check if the DNS resolution is correct.
     
  • DNS Configuration: It allows you to query specific DNS servers and check if they are correctly resolving domain names.
     
  • Mail Server Verification: You can use it to find the mail servers (MX records) for a domain, which is important for email configuration.
     
  • Interactive Mode: It offers an interactive mode where you can change query types, set DNS servers, and perform multiple queries without exiting the tool.

nslookup Command Options

We can use different options of this command to get detailed information from a domain name or an IP address. Some of them are:

Command Options

Function

-domain

It changes the DNS name.

-debug

It shows the information about debugging.

-port

It changes the port number to the value specified.

-timeout

It specifies the time limit for the server to reply.

-type=a

It views information about the DNS A address records.

-type=any

It views all records available.

-type=hinfo

It displays hardware-related information about the specified host.

-type=mx

It views the mail exchange information of the server.

-type=ns

It views the name server records.

-type=soa

It displays the start of the authority records.

-type=txt

It displays the text records of the domain name server.

 

Examples of nslookup command

We will see the use of the following options of nslookup command in this article:

  • nslookup [Domain name] 
     
  • nslookup [IP Address]
     
  • debug
     
  • timeout
     
  • type=ns
     
  • type=mx
     
  • type=a
     
  • type=txt
     
  • type=hinfo
     
  • type=soa
     
  • type=any


Now, let us discuss these functions one by one.

nslookup [Domain name]

This option returns the IP address of the domain name provided. We can use the following command:

$ nslookup codingninjas.com


Output

nslookup domain name

nslookup [IP Address]

This option reverses the DNS lookup. We provide the IP address as the argument. We can use the following command:

$ nslookup 13.35.128.61


Output

nslookup ip address

debug

It enables the debug mode and gives all the details about the domain name provided. We can use the following command:

$ nslookup -debug google.com


Output

debug command in nslookup
nslookup debug command output

timeout

It sets the time limit in which the server can reply. We can use the following command:

$ nslookup -timeout=10 codingninjas.com


Output

nslookup timeout

type=ns

We use this option to display the Name Server record mapping the domain name to the DNS servers. We can use the following command:

$ nslookup -timeout=10 -type=ns codingninjas.com


Output

nslookup -type=ns

type=mx

We use this option to display the mail exchange information of the server. We can use the following command:

$ nslookup -timeout=10 -type=mx codingninjas.com


Output

nslookup -type=mx

type=a

We use this option to display all the available DNS records for the specified record. We can use the following command:

$ nslookup -timeout=10 -type=a codingninjas.com


Output

nslookup -type=a

type=txt

We use this option to display the text records of the domain name server. We can use the following command:

$ nslookup -timeout=10 -type=txt facebook.com


Output

nslookup -type=txt

type=hinfo

This option displays hardware-related information about the specified host. We can use the following command:

$ nslookup -timeout=10 -type=hinfo codingninjas.com


Output

nslookup -type=hinfo

type=soa

This option displays the start of the authority records. It shows the authoritative records. We can use the following command:

$ nslookup -type=soa google.com


Output

nslookup -type=soa output

type=any

This option displays all the DNS records available. We can use the following command:

$ nslookup -type=any google.co.in

 

Output

nslookup type=any output

Also see, Nmap commands

Frequently Asked Questions

What is the full form of nslookup?

The full form of "nslookup" is "Name Server Lookup." It's a command-line tool used to query and retrieve information from Domain Name System (DNS) servers, like IP addresses for domain names.

How do I get the IP address from nslookup?

To get an IP address using nslookup, open your command prompt or terminal, type "nslookup," followed by the domain name, and press Enter. The IP address will be displayed.

What is the nslookup tool used for?

The nslookup tool is used for querying and retrieving information from Domain Name System (DNS) servers. It helps find IP addresses associated with domain names and troubleshoot network and DNS issues.

What is nslookup in DNS server?

In a DNS server context, nslookup is a command-line tool used to query the DNS server for information about domain names, such as IP addresses and other DNS records.

What is nslookup command in Linux?

In Linux, the "nslookup" command is a network utility that allows users to query and retrieve information from Domain Name System (DNS) servers, such as resolving domain names to IP addresses.

How to use nslookup command in Windows?

To find the A record for a domain, just type "nslookup domain_name" in the command prompt, and it will show you the result.

Conclusion

Domain names, IP addresses, DNS records, etc., are all vital components of computer networks. In this article, we studied the nslookup command in Linux, its options, and some examples showcasing its use.

If you are more inclined towards this topic, do read Linux, Network Commands.

To learn more about DSA, competitive coding, and many more knowledgeable topics, please look into the guided paths on Coding Ninjas Studio. Also, you can enroll in our courses and check out the mock test and problems available. Please check out our interview experiences and interview bundle for placement preparations.

Happy Coding!

Live masterclass