Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Shell Scripting
  • Kali Linux
  • Ubuntu
  • Red Hat
  • CentOS
  • Docker in Linux
  • Kubernetes in Linux
  • Linux interview question
  • Python
  • R
  • Java
  • C
  • C++
  • JavaScript
  • DSA
Open In App
Next Article:
Paste command in Linux with examples
Next article icon

Nslookup Command in Linux with Examples

Last Updated : 09 Apr, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Nslookup (stands for “Name Server Lookup”) is a useful command for getting information from the DNS server. It is a network administration tool for querying the Domain Name System (DNS) to obtain domain name or IP address mapping or any other specific DNS record. It is also used to troubleshoot DNS-related problems.

In easy words, imagine the internet as a giant neighborhood. Websites are like houses, but instead of street names, they have easy-to-remember addresses like “google.com”. However, computers communicate using numbers, so they need a way to find these houses. That’s where DNS comes in. It acts like a phonebook, translating those friendly website names into numerical addresses (IP addresses) that computers can understand.

Now, the nslookup command is like a special tool you can use to explore this phonebook. It lets you ask questions about websites and how they’re connected. You can use it to:

  • Look up a website’s address: Just like looking up a phone number in a phonebook, you can use nslookup to find the IP address of a website.
  • Troubleshoot problems: If you’re having trouble accessing a website, nslookup can help you pinpoint where the issue might lie.
  • Learn more about domain configurations: By using nslookup, you can discover details about a website’s domain, such as the servers responsible for managing it.

Syntax of the nslookup Command in Linux

The syntax of the nslookup command is relatively straightforward, typically taking the form:

nslookup [option] [domain]

Where:

  • [options] refer to additional parameters that modify the behavior of the command.
  • [domain] denotes the domain name or IP address to be queried.

Options of nslookup command:  

Options Description
-domain=[domain-name] allows you to change the default DNS name.
-debug enables the display of debugging information.
-port=[port-number] Use the -port option to specify the port number for queries. By default, nslookup uses port 53 for DNS queries
-timeout=[seconds] you can specify the time allowed for the DNS server to respond. By default, the timeout is set to a few seconds
-type=a Lookup for a record 
We can also view all the available DNS records for a particular record using the -type=a option
-type=any  Lookup for any record 
We can also view all the available DNS records using the -type=any option. 
-type=hinfo  displays hardware-related information about the host. It provides details about the operating system and hardware platform
-type=mx   Lookup for an mx record 
MX (Mail Exchange) maps a domain name to a list of mail exchange servers for that domain. The MX record says that all the mails sent to “google.com” should be routed to the Mail server in that domain. 
-type=ns Lookup for an ns record 
NS (Name Server) record maps a domain name to a list of DNS servers authoritative for that domain. It will output the name serves which are associated with the given domain. 
-type=ptr  used in reverse DNS lookups. It retrieves the Pointer (PTR) records, which map IP addresses to domain names.
-type=soa Lookup for a soa record 
SOA record (start of authority), provides the authoritative information about the domain, the e-mail address of the domain admin, the domain serial number, etc… 

Examples of Some Most Command Options of nslookup in Linux

  • Performing a basic DNS lookup
  • Performing a reverse DNS lookup
  • Using `-type=any` option 
  • Using `-type=soa` option 
  • Using `-type=ns` option 
  • Using `-type=a` option 
  • Using `-type=mx` option 
  • Using `-type=txt` option 

Performing a basic DNS lookup

Syntax:

nslookup example.com

Example:

nslookup google.com

nslookup followed by the domain name will display the “A Record” (IP Address) of the domain. Use this command to find the address record for a domain. It queries domain name servers and gets the details. 

nslookup google.com

nslookup google.com

Performing a reverse DNS lookup

Syntax:

nslookup [IP Address]

Example:

nslookup 192.168.0.10

 You can also do the reverse DNS look-up by providing the IP Address as an argument to nslookup. 

nslookup 192.168.0.10

nslookup 192.168.0.10

Using `-type=any` option 

Syntax:

nslookup -type=any google.com

 Lookup for any record We can also view all the available DNS records using the -type=any option. 

nslookup -type=any google.com

nslookup -type=any google.com

Using `-type=soa` option 

Syntax:

nslookup -type=soa redhat.com

Lookup for a soa record SOA record (start of authority), provides the authoritative information about the domain, the e-mail address of the domain admin, the domain serial number, etc… 

nslookup -type=soa redhat.com

nslookup -type=soa redhat.com

Using `-type=ns` option 

Syntax:

nslookup -type=ns google.com

 Lookup for an ns record. NS (Name Server) record maps a domain name to a list of DNS servers authoritative for that domain. It will output the name serves which are associated with the given domain. 

nslookup -type=ns google.com

nslookup -type=ns google.com

Using `-type=a` option 

Syntax:

nslookup -type=a google.com

Lookup for a record. We can also view all the available DNS records for a particular record using the -type=a option. 

nslookup -type=a google.com

nslookup -type=a google.com

Using `-type=mx` option 

Syntax:

nslookup -type=mx google.com

Lookup for an mx record. MX (Mail Exchange) maps a domain name to a list of mail exchange servers for that domain. The MX record says that all the mails sent to “google.com” should be routed to the Mail server in that domain. 

nslookup -type=mx google.com

nslookup -type=mx google.com

Using `-type=txt` option 

Syntax:

nslookup -type=txt google.com

Lookup for a txt record. TXT records are useful for multiple types of records like DKIM, SPF, etc. You can find all TXT records configured for any domain using the command below. 

nslookup -type=txt google.com

nslookup -type=txt google.com

Conclusion

In this article we have discussed the `nslookup` command which is a variable tool for querying the DNS server and obtaining information about domain name or IP address mapping. We have studied that it is very useful for troubleshooting DNS-related issues. We have also discussed options like -type=a, -type=any, -type=mx, -type=ns, -type=ptr, and -type=soa. Overall, we can say that by using nslookup information, administrators can gain insights into the DNS infrastructure and resolve DNS-related problems efficiently.



Next Article
Paste command in Linux with examples

M

mahimabadjate
Improve
Article Tags :
  • Linux-Unix

Similar Reads

  • How to Read Manual Pages in Linux | man Command
    The "man" command, short for manual, is a powerful tool in the Linux operating system that allows users to access detailed information about various commands, utilities, and system calls. The "man" command provides comprehensive documentation, helping users understand how to use and configure differ
    9 min read
  • md5sum Command in Linux with Examples
    The md5sum is designed to verify data integrity using MD5 (Message Digest Algorithm 5). MD5 is 128-bit cryptographic hash and if used properly it can be used to verify file authenticity and integrity. Example : Input : md5sum /home/mandeep/test/test.cppOutput : c6779ec2960296ed9a04f08d67f64422 /home
    5 min read
  • How to Create Directory in Linux | mkdir Command
    In Linux, the 'mkdir' command is like a magic wand for creating folders super easily. 'mkdir' stands for "make directory," and it helps you organize your computer stuff by creating folders with just one command. Whether you're making one folder or a bunch of them in a row, 'mkdir' is there to help y
    7 min read
  • modinfo command in Linux with Examples
    The modinfo command in Linux is used to display information about a Linux kernel module. It extracts detailed information from the modules available in the system and provides insights into their properties, dependencies, parameters, and more. If the module name is provided without a file name, the
    3 min read
  • more command in Linux with Examples
    The 'more' command in Linux is a useful tool for viewing text files in the command prompt, particularly when dealing with large files like log files. It displays the content one screen at a time, allowing users to scroll through the text easily. This command is especially handy for reviewing long ou
    4 min read
  • How to Mount File System in Linux | mount Command
    Working with file systems is a fundamental part of managing a Linux system, and knowing how to mount them is a skill every Linux user should have. Whether you’re connecting a USB drive, accessing a network share, or setting up a new partition, the mount command is your go-to tool for making file sys
    7 min read
  • mpstat Command in Linux with Examples
    mpstat is a powerful and versatile command-line tool within a Linux system that allows detailed reporting of various processor-related statistics. Indeed, part of the sysstat package, mpstat delivers comprehensive CPU utilization and performance data, thus becoming an essential utility for both syst
    5 min read
  • How to Move File in Linux | mv Command
    The `mv` command in Linux is like a superhero tool that can do a bunch of cool stuff with your files and folders. Think of it as a digital moving truck that helps you shift things around in your computer. Whether you want to tidy up your folders, give your files new names, or send them to different
    7 min read
  • Practical Uses of nc(netcat) command in Linux
    Netcat is one of the most powerful networking tools, security tools, and network monitoring tools. It is even considered a Swiss army knife of networking tools. It acts like a cat command over a network. It is generally used for the following reasons: Operation related to TCP, UDP, or UNIX-domain so
    8 min read
  • Netstat command in Linux
    The netstat command is like a special tool in Linux that helps you understand and check things about how your computer connects to the internet. It can tell you about the connections your computer is making, the paths it uses to send information, and even some technical details like how many packets
    7 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences