13.12.2024

The nslookup utility: how to use it?

Working with infrastructure often requires additional tools and utilities to help with trabshooting and solving network and service configuration tasks, one such tool is nslookup!

In this article we will look at what it is and why it is used in the process of checking configurations and network connections.э

What is nslookup?

Nslookup is a DNS troubleshooting utility that allows you to get IP addresses from domain names and vice versa using server records.

Important term to introduce: reslov is the process of mapping a domain to records

For example, typically a server has a list of different records for its gg[.]com domain:

And the utility, having addressed with a request, where the record type and domain will be specified, will receive a reply with the address or other requested information.

Screenshot №1 - Usage

On Windows, nslookup is installed, by default, and can be invoked via Win+X → Terminal/PowerShell:

nslookup /help

For Linux, you can use a similar dig utility by first installing a package with it:

apt install net-tools -y && dig --help

How do I use nslookup?

The syntax of the utility itself is a classic set of passed options and arguments:

nslookup -[options] host server

Screenshot №2 - Help

Where nslookup is the command to invoke the utility, -opt options, host is the requested resource on the resolv or mapping, and server is the DNS server to which the resolv request will go. The options can be as follows.

To view the address that the domain is referencing you can command:

nslookup -type A google.com

Or specify a different DNS-server for it, this can be useful when testing external and internal service:

nslookup -type A google.com 8.8.8.8.8

-type=<type> Specifies the type of DNS record you want to query:

A - address (IPv4);
AAAA - address (IPv6);
CNAME - canonical name;
MX - mail server;
NS - name server records;
PTR - reverse records;
SOA - initial zone entry;
TXT - text records.

If the DNS service uses a non-standard port, it can be accessed with the custom option:

nslookup -port=5156 google.com

When the network connection is not the fastest, you may need to increase the response time:

nslookup -timeout=10 google.com

To see the details of the response, use the -debug option, and to increase the number of attempts, specify them directly:

nslookup -retry=3 -debug example.com

Such a solution will be of great help when checking the configuration of DNS-server or paths accessed by the device. For example, if the gg.com site does not open, the answer to the nslookup request says that the ip address is 192.168.1.1, which is not accessible to the device! Thus you can trabshooting on interaction of DNS-server and devices in the network!

As a result of executing these commands you should get a list of parameters of the requested objects. If you don't have sufficient resources than you can perform actions on powerful cloud servers. Serverspace provides isolated VPS / VDS servers for common and virtualize usage.

Screenshot №3 — Create Server