NSLOOKUP
Introduction
Having access to a website’s Domain Name System (DNS) records is helpful when resolving
DNS issues. Users can use tools found in all popular operating systems to query a web server
and obtain crucial data, like IP addresses and other domain-related details.
What is nslookup?
A command-line program called nslookup can be used to find the IP address or DNS record
associated with a certain domain name. Additionally, it enables reverse DNS lookup, which
enables you to identify the domain linked to an IP address. Enter “nslookup” into the
Command Prompt or Terminal to begin using the utility.
List of nslookup Commands
There are various types of nslookup commands for requesting different domain information.
The most commonly used commands include:
- name – shows information about the domain name or hostname using the default
server. - server name – sets a different default DNS server using the current one’s information.
- root – assigns the root server as the default.
- set type= – queries a specific DNS record type, such as A, MX, PTR, or SOA. Use ANY to display all server records.
- set debug – displays debugging information about each query and its corresponding
response. - set recurse – asks the DNS nameserver to query other servers if it can’t provide the
information. - help – shows a list of nslookup commands and their functions.
- exit – quits the nslookup tool and returns users to the CLI.
How to Use the nslookup Command
Nearly every operating system’s command-line program, such as Windows’ Command Prompt
or Linux and macOS’s Terminal, can be used to perform nslookup searches.
Although nslookup seems slightly different on different OSs, it functions similarly on them.
Here’s how it appears, for instance, in Linux:
Nslookup comes in two flavors: interactive and non-interactive. Although they both have
comparable functions, their intended applications differ.
By entering extra parameters in the interactive mode, users can ask nameservers for various
details about hosts or domains.
On the other hand, the non-interactive mode offers a single piece of data regarding a host or
domain.
In your CLI, type nslookup without arguments to launch the interactive mode. The address
bar, the default server name, and the line where you can enter a domain name or other
commands will all be shown.
Enter nslookup as the first parameter, followed by a domain name, to access the noninteractive mode. You can ask for different information by preceding the domain name with
different commands or by following it with a nameserver address.
You should type the domain and commands on the same line when using the non-interactive
mode. The interactive mode, on the other hand, employs a single line for each domain and
argument.
When accessing a website for the first time, your browser will ask the DNS resolver for the domain’s IP
address. The resolver will then ask the root server, directing the former to the domain’s top-level
domain (TLD) server.
Then, the TLD server will send a response, directing the resolver to the authoritative server.
The resolver will ask the authoritative server for information, which includes its IP address and
DNS record.
Next, the authoritative server will send the queried domain’s address and DNS records back to
the resolver, which forwards it to the client. The web browser can now connect to the domain
upon receiving the IP address.
The client and resolver servers will store the domain’s information locally as a DNS cache.
Therefore, when the user reaccesses the same domain, there is no need to repeat the entire
process. The browser can simply fetch the IP address from the DNS cache.
Non-authoritative answers are possibly outdated because the information is fetched from the
cache. They are unsuitable for troubleshooting purposes. To get an authoritative answer, enter:
nslookup -type=soa domainname.tld
This will query the standard of authority (SOA) record containing important information about
the specified domain. For example, you want to get an authoritative response for the domain
google.com:
View Domain’s NS Records
Name Server (NS) records store names of the domain’s name servers. To see a domain’s NS
records, type:
nslookup -type=ns [domain-name]
The output lists all available name servers:
View Domains MX Records
All pertinent Mail Exchange server data is stored in MX records. All email requests for the
domain are routed to the relevant mail server using this information.
Check a domain’s MX data by typing:
nslookup -type=mx [domain-name]
The output shows the names of mail servers.
Perform a Reverse DNS
Lookup
In addition to offering details about domain names, nslookup can be used to locate the domain
name linked to an IP address.
Perform a reverse DNS lookup using the following syntax:
nslookup [ip-address]
The command outputs the domain name.
View Text Records
Important information for users outside of the domain can be found in TXT records. For
instance, TXT records are used by Facebook and Google to confirm domain ownership.
View a domain’s TXT information by running the following nslookup command:
nslookup -type=txt [domain-name]
The output shows each TXT record in a separate line:
View Debugging Information
To view information useful for debugging, use the debug option:
nslookup -debug