How to use Nslookup in Debian

Nslookup or name server lookup is a tool used by network administrators to find the hostname, IP address or other DNS records such as MX records, NS records, etc. It is often used to fix DNS related issues.

In this article, we will explain how to use Nslookup to query different types of DNS records. We have run the commands and procedure mentioned in this article on a Debian 10 OS. However, the same procedure can be followed in other distributions and versions of Linux as well.

There are two modes in which Nslookup works: Interactive mode and Non-interactive mode. We have explained the procedure in not-interactive mode. However, at the end will also learn how to use the interactive mode.

Nslookup Non-interactive mode

In non-interactive mode, the entire command is issued at the Terminal. Use this mode when you require a single piece of information from a particular server.

For using non-interactive mode, the general syntax is:

$ nslookup [option] [hostname] [DNS server or IP]

How it works?

Open the Terminal in your Debian OS. In the top left corner of your desktop, you will see the Activities tab. By clicking this tab, a search bar will appear. From there, you can search for Terminal application.

Obtain IP address for a hostname

In order to find the IP address for a hostname, the syntax is:


This method is also known as forward DNS lookup.

For instance, to find the IP address of, enter the following command in Terminal:

$ nslookup

The above command implies that the Nslookup has requests the DNS server to find the IP address of The DNS server then requests to other servers, get a response and then sending it back to the Nslookup.

In the Terminal, you will receive the following info:

Understanding the output

The above output has provided us with some findings. Let’s understand them:


# It is the IP address of the DNS server to which Nslookup requested to.


# It is the IP address of the DNS server along with the port number 53 Nslookup talked to.

Non-authoritative answer

# Non-authoritative answer indicates we have got the cached reply from the DNS server.

Obtain hostname from IP address

We can also perform reverse Nslookup to resolve hostname against an IP address. It is known as reverse DNS lookup.

The syntax of the command is:

$ nslookup IP_address

In the following example, we are finding the hostname against the IP as follows:

$ nslookup

From the following output, you can see that Nslookup has returned the hostname against the specified IP address.

Obtain MX records

MX ( Mail Exchange ) records determine the mail server settings configured for a specific domain. It contains the mapping of a domain name to a list of email servers.  MX records tells which mail server will handle the mails sent to a specific domain. MX records are configured in such a way that when an email is sent to, it is routed to the mail servers for the domain

To find the MX records for a specific domain, the syntax is:

$ nslookup -query=mx

In the following example, we are finding the MX records for the domain

$ nslookup –query=mx

The following output shows the MX records for the domain

Obtain NS records

In the domain name system, NS records are used to identify which name servers are responsible and authoritative for a domain.

To find the NS  records for a specific domain, the syntax is:

$ nslookup -query=mx

In the following example, we are finding the NS records for the domain

$ nslookup -query=mx

The following output shows the NS records for the domain

Obtain all DNS records

Nslookup can also be used to retrieve all the records simultaneously including A, NS, MX, TXT, SPF, etc. for the hostname you specify.

To find all the DNS records, use the following syntax:

$ nslookup -query=any <URL>

For instance, to find all DNS records of a domain, the command would be:

$ nslookup -query=any

Nslookup Interactive mode

In interactive mode, you first enter in a separate prompt, and then add subsequent parameters to inquire further information. Use this mode when you require a lot of information from a server.

In order to use interactive mode, simply type nslookup in Terminal and press Enter.

$ nslookup

You will see the prompt like >. Here you can query for information.

In the following example, after entering in the Nslookup prompt, we have entered the following commands:

# To obtain IP address information for the domain


# To obtain MX records for the domain

> set query=mx

As we have seen, Nslookup provides a lot of information regarding DNS such as forward and reverse lookup information, NS records, MX records, etc. However, it is not limited to just this information rather it provides a lot more than this. But for now, we hope it would be enough for you to have a basic understanding of Nslookup works.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Using Consul DNS Interface

The DNS interface of Consul will help you to achieve service discovery without any personal-touch integration with the...

DnsCrypt on Ubuntu – Encrypted DNS Traffic

DNSCrypt is an authentication protocol that facilitates the communication between DNS clients and DNS resolvers.  It’s...

How to Configure dnsmasq on Ubuntu Server 18.04 LTS

dnsmasq is a very lightweight local DNS server. dnsmasq can also be configured as a DNS cache server and DHCP server. dnsmasq...
Bài Viết

Bài Viết Mới Cập Nhật


Mua Proxy v6 US Private chạy PRE, Face, Insta, Gmail

Mua shadowsocks và hướng dẫn sữ dụng trên window

Tại sao Proxy Socks lại được ưa chuộng hơn Proxy HTTP?

Mua thuê proxy v4 nuôi zalo chất lượng cao, kinh nghiệm tránh quét tài khoản zalo