How to Use the nslookup Command {10 Examples} (2024)

Introduction

When troubleshooting DNS issues, it is useful to have access to Domain Name System (DNS) records of a website. All mainstream operating systems have tools that enable users to query a web server and receive important information such as IP addresses and other pieces of domain-related information.

This article will introduce the nslookup command which is used for obtaining server records. It will also provide examples of the command's most popular options.

How to Use the nslookup Command {10 Examples} (1)

Prerequisites

  • Access to the command line interface
  • Access to internet

Note: If you are not familiar with DNS record types, we strongly recommend you read DNS Record Types Explained before diving into this article.

nslookup Syntax

The nslookup command can be used in two modes: interactive and non-interactive. To initiate the nslookup interactive mode, type the command name only:

nslookup

The prompt that appears lets you issue multiple server queries.

How to Use the nslookup Command {10 Examples} (2)

For example, you can type a domain name and receive information about it.

www.google.com

After nslookup outputs the information, it provides another prompt.

How to Use the nslookup Command {10 Examples} (3)

In interactive mode, specify an option in a separate line before the query. Precede the option with set:

set [option]

To exit interactive mode, type:

exit

The non-interactive mode lets you use nslookup to issue single queries. The syntax for the non-interactive mode is:

nslookup [options] [domain-name]

The command and the query are written in the same line.

How to Use the nslookup Command {10 Examples} (5)

nslookup Options

Find all the important nslookup options in the following table.

nslookup OptionDescription
-domain=[domain-name]Change the default DNS name.
-debugShow debugging information.
-port=[port-number]Specify the port for queries. The default port number is 53.
-timeout=[seconds]Specify the time allowed for the server to respond.
-type=aView information about the DNS A address records.
-type=anyView all available records.
-type=hinfoView hardware-related information about the host.
-type=mxView Mail Exchange server information.
-type=nsView Name Server records.
-type=ptrView Pointer records. Used in reverse DNS lookups.
-type=soaView Start of Authority records.

Installing nslookup

nslookup comes preinstalled on all major operating systems. If you need to install it again on Ubuntu or another Linux distro featuring the APT package manager, install the dnsutils package:

sudo apt install dnsutils

On CentOS, Fedora, and Red Hat, nslookup is part of the bind-utils package. Install it by running:

sudo dnf install bind-utils

How to Use nslookup?

Use the nslookup command to perform DNS and reverse DNS searches and troubleshoot server-related problems. The following sections present the most common uses of the command.

Note: The authoritative answer in the output of the nslookup refers to the answer provided by one of the nameservers belonging to the domain being searched. The non-authoritative answer is provided by a nameserver not associated with the specific domain, e.g., your ISP nameserver.

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:

How to Use the nslookup Command {10 Examples} (6)

View Domains MX Records

MX records store all relevant Mail Exchange server data. This information is used to route all email requests for the domain to the appropriate mail server.

Check a domain's MX data by typing:

nslookup -type=mx [domain-name]

The output shows the names of mail servers.

How to Use the nslookup Command {10 Examples} (7)

Perform a Reverse DNS Lookup

While nslookup provides information about a domain name, it can also be used to look for the domain name associated with an IP address.

Perform a reverse DNS lookup using the following syntax:

nslookup [ip-address]

The command outputs the domain name.

How to Use the nslookup Command {10 Examples} (8)

View SOA Records

Start of Authority (SOA) records provide authoritative information about the domain and the server, such as the email address of the administrator, serial number, refresh interval, query expiration time, etc.

View a domain's SOA records by typing:

nslookup -type=soa [domain-name]

The nslookup command output shows the relevant information:

How to Use the nslookup Command {10 Examples} (9)

View Text Records

TXT records contain important information for users outside of the domain. For example, Google and Facebook use TXT records to verify 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:

How to Use the nslookup Command {10 Examples} (10)

View All Records

View all available DNS records of a domain using the any option.

nslookup -type=any [domain-name]

The output shows NS, SOA, MX, and TXT information:

How to Use the nslookup Command {10 Examples} (11)

View Information About a Specific Name Server

See the name, IPv4 and IPv6 information of a specific name server on a domain by using the following syntax:

nslookup [domain-name] [name-server]

The output is now limited to the nameserver you specified:

How to Use the nslookup Command {10 Examples} (12)

View Pointer Records

Pointer records are used for reverse DNS lookups to confirm that the IP address belongs to a specific domain name. When using the ptr option, type the IP address in reverse, i.e., 1.2.3.4 becomes 4.3.2.1:

nslookup -type=ptr [reverse-ip-address].in-addr.arpa

Look for the domain name in the output.

How to Use the nslookup Command {10 Examples} (13)

Query a Non-Default Port

DNS servers use port 53 to communicate. If you want to check a different port, specify it with the port option:

nslookup -port=[port-number] [domain-name]

View Debugging Information

To view information useful for debugging, use the debug option:

nslookup -debug [domain-name]
How to Use the nslookup Command {10 Examples} (14)

Note: In the interactive mode, setting the debug option turns on the debugging mode. To exit the mode, set the nodebug option.

Conclusion

After reading this article, you should know how to install and use the nslookup command on Linux. The article provided examples of the most common uses of nslookup.

How to Use the nslookup Command {10 Examples} (2024)
Top Articles
Cheat With Science: Win a Coin Toss
Store domain credentials in Azure Key Vault - Azure Monitor
Uti Hvacr
Ghosted Imdb Parents Guide
Pga Scores Cbs
PontiacMadeDDG family: mother, father and siblings
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Nashville Predators Wiki
6th gen chevy camaro forumCamaro ZL1 Z28 SS LT Camaro forums, news, blog, reviews, wallpapers, pricing – Camaro5.com
FAQ: Pressure-Treated Wood
Alejos Hut Henderson Tx
Tcgplayer Store
Grasons Estate Sales Tucson
Costco Gas Foster City
Enterprise Car Sales Jacksonville Used Cars
Cpt 90677 Reimbursem*nt 2023
Nine Perfect Strangers (Miniserie, 2021)
Why Is 365 Market Troy Mi On My Bank Statement
If you bought Canned or Pouched Tuna between June 1, 2011 and July 1, 2015, you may qualify to get cash from class action settlements totaling $152.2 million
/Www.usps.com/International/Passports.htm
Long Island Jobs Craigslist
Mail.zsthost Change Password
EASYfelt Plafondeiland
Allybearloves
Pecos Valley Sunland Park Menu
Football - 2024/2025 Women’s Super League: Preview, schedule and how to watch
Dragger Games For The Brain
Magic Seaweed Daytona
PCM.daily - Discussion Forum: Classique du Grand Duché
SN100C, An Australia Trademark of Nihon Superior Co., Ltd.. Application Number: 2480607 :: Trademark Elite Trademarks
Wisconsin Volleyball Team Boobs Uncensored
A Cup of Cozy – Podcast
Mississippi Craigslist
Eegees Gift Card Balance
Pipa Mountain Hot Pot渝味晓宇重庆老火锅 Menu
UPC Code Lookup: Free UPC Code Lookup With Major Retailers
The Wichita Beacon from Wichita, Kansas
Texas Baseball Officially Releases 2023 Schedule
42 Manufacturing jobs in Grayling
Daily Jail Count - Harrison County Sheriff's Office - Mississippi
Ukraine-Krieg - Militärexperte: "Momentum bei den Russen"
Atom Tickets – Buy Movie Tickets, Invite Friends, Skip Lines
Walgreens On Secor And Alexis
What Is The Optavia Diet—And How Does It Work?
Florida Lottery Powerball Double Play
Beds From Rent-A-Center
Hsi Delphi Forum
Divisadero Florist
Vt Craiglist
Syrie Funeral Home Obituary
Latest Posts
Article information

Author: Maia Crooks Jr

Last Updated:

Views: 6124

Rating: 4.2 / 5 (63 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Maia Crooks Jr

Birthday: 1997-09-21

Address: 93119 Joseph Street, Peggyfurt, NC 11582

Phone: +2983088926881

Job: Principal Design Liaison

Hobby: Web surfing, Skiing, role-playing games, Sketching, Polo, Sewing, Genealogy

Introduction: My name is Maia Crooks Jr, I am a homely, joyous, shiny, successful, hilarious, thoughtful, joyous person who loves writing and wants to share my knowledge and understanding with you.