nslookup utility can be installed and used on a Linux system to find out information about the DNS records for a domain or IP address. It’s particularly handy when troubleshooting DNS issues. A popular tool that also comes installed with nslookup is
dig, which is similar but uses different resolvers. It’s a good alternative to nslookup, but nslookup is typically easier to use.
In this tutorial, we’ll guide you through the installation of nslookup on major Linux distributions and show various command line examples that you can use on your own system when you need to obtain DNS information.
In this tutorial you will learn:
- How to install nslookup on major Linux distros
- Nslookup command line examples
|Category||Requirements, Conventions or Software Version Used|
|System||Any Linux distro|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
There’s a good chance that nslookup is already installed on your system and ready to use. But, if not, just use the appropriate command below to install it.
$ sudo apt install dnsutils
$ sudo dnf install bind-utils
$ sudo pacman -S dnsutils
Nslookup command line examples
Now that nslookup is installed, try some of the following commands to get a feel for how it works.
To see basic information about a domain’s A record, simply specify the domain name as an argument. The output may contain multiple IP addresses, depending on the queried server’s configuration.
$ nslookup redhat.com Server: 127.0.0.53 Address: 127.0.0.53#53 Non-authoritative answer: Name: redhat.com Address: 184.108.40.206
You can also look up the reverse DNS record by specifying the IP address and seeing which domain name it points to.
$ nslookup 220.127.116.11 18.104.22.168.in-addr.arpa name = redirect.redhat.com.
To see the mail record (MX) for a domain, use the
-query=MX option. This record controls where mail sent to the domain (in this case, @redhat.com) is sent to.
$ nslookup -query=mx redhat.com Server: 127.0.0.53 Address: 127.0.0.53#53 Non-authoritative answer: redhat.com mail exchanger = 10 us-smtp-inbound-2.mimecast.com. redhat.com mail exchanger = 10 us-smtp-inbound-1.mimecast.com.
-query=ns option to see a list of DNS servers for the domain.
$ nslookup -type=ns redhat.com Server: 127.0.0.53 Address: 127.0.0.53#53 Non-authoritative answer: redhat.com nameserver = a10-65.akam.net. redhat.com nameserver = a9-65.akam.net. redhat.com nameserver = a13-66.akam.net. redhat.com nameserver = a28-64.akam.net. redhat.com nameserver = a1-68.akam.net. redhat.com nameserver = a16-67.akam.net.
These are some of the main options for nslookup, although there are more query types available and further options. Check out the man page for more details, and maybe give the dig command a try as well.
$ man nslookup AND $ man dig
In this guide, we learned how to install the nslookup utility on major Linux distributions. We also saw several example commands for querying DNS information from a domain name and IP address. The nslookup command is super handy when you need to see a concise list of DNS information.