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: