Skip to main content

Module 9: Networking

Lesson 86: nslookup Command

In this lesson, you'll learn how to use the nslookup command to query DNS servers and look up domain name information in Linux.

nslookup is a command-line administrative tool for testing and troubleshooting DNS servers (Domain Name Server).

It is also used to query specific DNS resource records (RR). Most operating systems come with a built-in nslookup feature.

It can be run in two modes: Interactive and Non-Interactive.

The Interactive mode is used to query DNS-Server about various domains and hosts. The Non-Interactive mode is used to query information about a domain or host.

nslookup Command Syntax

# nslookup [OPTIONS] [DOMAIN] [DNS_SERVER]

nslookup Command Options

Option Description
-query=mx Query Mail Exchange (MX) records
-query=ns Query Name Server (NS) records
-query=any Query all available DNS records
-type=soa Query Start of Authority (SOA) records
-debug Enable debug mode for verbose TTL information

1. Find the "A" Record (IP Address) of a Domain

To look up the "A" record (IP address) of a domain, pass the domain name as an argument to nslookup.

# nslookup yahoo.com
Server:		127.0.0.53
Address:	127.0.0.53#53

Non-authoritative answer:
Name:	yahoo.com
Address: 74.6.231.20
Name:	yahoo.com
Address: 74.6.143.25
Name:	yahoo.com
Address: 98.137.11.163
Name:	yahoo.com
Address: 74.6.231.21
Name:	yahoo.com
Address: 98.137.11.164
Name:	yahoo.com
Address: 74.6.143.26
Name:	yahoo.com
Address: 2001:4998:44:3507::8001
Name:	yahoo.com
Address: 2001:4998:124:1507::f000
Name:	yahoo.com
Address: 2001:4998:124:1507::f001
Name:	yahoo.com
Address: 2001:4998:24:120d::1:1
Name:	yahoo.com
Address: 2001:4998:24:120d::1:0
Name:	yahoo.com
Address: 2001:4998:44:3507::8000

The above command queries the domain yahoo.com with the 4.2.2.2 public DNS server, and the below section shows Non-authoritative answer: which displays the A record of yahoo.com.

2. Find out Reverse Domain Lookup

To perform a reverse DNS lookup, pass the IP address as an argument to nslookup.

# nslookup 74.6.143.26
26.143.6.74.in-addr.arpa	name = media-router-fp74.prod.media.vip.bf1.yahoo.com.

Authoritative answers can be found from:

3. Find out Specific Domain Lookup

Pro TecMint Β· Root Plan
This Article is for Root Members
Join Root to read the full article and unlock everything

Full Access to Every Article, Course & Certification Track

Join thousands of Linux professionals who use Pro TecMint to advance their careers.

Ad-free access to all premium articles
All courses: Learn Linux, Bash, Golang, Ubuntu and more
RHCSA, RHCE, LFCS & LFCA certification prep
New courses added every month
Private Telegram community & priority support
Root Plan
$8/mo
or $59/year billed annually
Save $37 with annual plan
Start Reading This Article in the Next 60 Seconds
Join Root Plan β†’