Learn how to use nslookup command in Ubuntu such as 22.04 or 20.04 to check the DNS records for a website domain.
The Domain Name System (DNS) is a central directory service that is responsible for name resolution on the Internet. If problems arise, it can sometimes be useful to take a look behind the scenes and, for example, to determine an IP address for a hostname. A useful tool for this purpose is nslookup, which we will introduce to you in more detail in this post.
What is nslookup?
nslookup (“name server lookup”) is a handy little command line tool that allows you to find the IP address to a hostname (DNS lookup) or (vice versa) the domain name to a specific IP address (reverse DNS). It can be executed from the command line of the respective operating system. It works on all working operating systems such as Windows, Linux, and macOS.
Steps to check in DNS records for a domain in Ubuntu
The given commands to view DNS records on Linux will work on all Ubuntu and Debian distros such as Linux Mint, POP OS, and more…
1. Install NSlookup in Ubuntu
Well, we don’t need to install NSlookup in Ubuntu because it is already on your system. Hence, only you should know how to use it for getting records such as AAA, A, TXT, MX, and more… Let’s see how to view all such DNS records using this tool.
However, if you don’t have this DNS lookup tool, then here is the command to install NSlookup:
sudo apt install dnsutils
2. Command to check ‘A’ DNS record
Now, let’s say you just want to view the ‘A‘ DNS record or IP address on Linux of any domain available online or in your local network and accessible too, then here is the command to follow.
nslookup your-domain-name
For example:
nslookup facebook.com
Output:
Server: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
Name: facebook.com
Address: 157.240.1.35
Name: facebook.com
Address: 2a03:2880:f16b:81:face:b00c:0:25de
3. Reverse DNS lookup in Ubuntu Linux
Now, let’s say you have an IP address of some domain but don’t know, for which domain exactly then we can use the nslookup for reverse DNS lookup.
syntax:
nslookup ip-address
example:
nslookup 157.240.1.35

Note: In the above screenshot, you can see two values providing the answers to your query. One is Non-Authoritative– The output given under it by NSlookup means the answer displayed is not fetched by one of the nameservers associated with the Domain you have searched for; instead by some other such as your ISP nameserver; the other is Authoritative Answer, the values displayed under this are provided by the official the Nameservers belongs to the searched domain.
4. nslookup common Options
For those who are looking for options to view a single type of DNS record using the NSlookup then here are those:
nslookup Option | Explanation |
---|---|
-debug | To get debug info |
-port=[port-number] | To check the DNS record at some specific port, by default it uses 53 |
-timeout=[seconds] | If the server is slow, you can assign some time to your query command to wait until you receive the DNS record details |
-type=a | This option is to get the DNS A address records. |
-type=any | To check any type of available records details of a domain or website |
-type=txt | View TXT records like DKIM, SPF, etc. |
-type=mx | Nslookup option to have records available for the Mail Exchange server |
-type=ns | To view DNS records available for Domain’s Name Server. |
-type=ptr | View Pointer records. Used in reverse DNS lookups. |
-type=soa | To check the Start of Authority records |
Now, let’s see how to use the above options of NSlookup:
5. View all Domain DNS records
Let’s say you don’t have any particular DNS record type in mind to view for a particular website Domain. In such case, to have a general idea we can run a command to check all the available records associated with a Domain. Here is the command of nslookup to use:
Syntax:
nslookup -type=any your-domain-name
Example:
nslookup -type=any facebook.com
You will have all the available records such as NS, A, TXT, and more…

6. View only A DNS record in Linux
Although we can get the A record or Ip-address information related to some domain without giving any paraments, however, if want to be specific then use it. Here is the way:
syntax:
nslookup -type=a your-domain-name
example:
nslookup -type=a www.how2shout.com

7. View Domain MX Records on Ubuntu
Next, check what are the available Mail Exchange records that are used by the DNS of a domain to route the Emails. Such records help Domain to make sure emails are going to the right mail server.
syntax
nslookup -type=mx your-domain-name
example:
nslookup -type=mx facebook.com

8. Command to Check for Domain NameServer records
Nameservers are the servers that are used to store the information related to a Domain name. They are responsible for converting the domain name into an IP address or vice versa. It is an essential part of our Domain Name System (DNS). For example, we type the domain name of some websites but the computer doesn’t understand that, here Nameservers come in. It translates that domain name into a valid Ip-address associated with that domain.
To view the available Nameservers DNS records on Linux for some Domain, we can use the following NSlookup command:
syntax:
nslookup -type=ns your-domain-name
example:
nslookup -type=ns facebook.com

9. View Domain SOA Records on Linux
The Start of Authority (DNS) SOA records in DNS are very important, they store the key information about a Domain or zone. Such as when was the last time the Domain was updated, the admin email address, and the amount of time secondary servers should wait to fetch the SOA record from the Primary Server if it has been updated. And also when servers should stop querying about SOA records. Also, in DNS zone transfer, the SOA records transfer first.
To view SOA DNS records on Linux using NsLookup, the syntax is:
nslookup -type=soa your-domain-name
example:
nslookup -type=soa how2shout.com

10. Check DNS Text Records in Ubuntu Terminal
TXT is another type of record maintained by the DNS server of a Domain to provide information about other multiple types of records such as DKIM, SPF, etc.
syntax:
nslookup -type=txt your-domain.com
example:
nslookup -type=txt google.com

11. Nslookup debug option
We also have Debug option to have more additional available information.
syntax
nslookup -debug your.domain.com
example
nslookup -debug facebook.com
Check out NSlookup Manpage on Ubuntu
Other Articles:
⇒ How to use the Whois command on Linux to see domain-info
⇒ How to set DNS Nameserver on Ubuntu 22.04 LTS Jammy
⇒ Set Up Nginx as a Reverse Proxy For Apache on Ubuntu 22.04
⇒ List of Commands to get Linux system info using terminal
⇒ 2 ways to find my IP address on Ubuntu 22.04 Jammy JellyFish