nslookup Command in Linux

Learn via video courses
Topics Covered

Build an AI-First Career, Master the Complete Skillset

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program
NSDC Certified

AI Forward Deployed Engineer Program

Full-stack engineering, production AI and client-facing consulting

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program

Overview

nslookup, short for 'name server lookup', is a command-line utility used for querying the Domain Name System (DNS) to obtain domain name or IP address mappings. It is widely used to troubleshoot DNS issues, resolve hostname to IP addresses, and vice versa.

Linux nslookup Command Syntax

The syntax for the nslookup command is as follows:

Where:

  • option: Options or flags to modify the behavior of nslookup.
  • name: The domain name or IP address you want to query.
  • server: The DNS server you want to use for the query.

nslookup Command Options:

  • -type=: Specify the type of DNS record to query, such as A, AAAA, MX, NS, CNAME, or SOA.
  • -debug: Display additional debugging information.
  • -norecurse: Disable recursive queries.
  • -timeout=: Set the query timeout in seconds.
Sharpen Your Fundamentals with Free Learning

Example Usages

  • Basic nslookup usage to find the IP address for a domain.:

    Output:

    Explanation: This command queries the default DNS server for the IP address associated with the domain 'example.com'. The output displays the server's IP address and the resolved IP address for the domain.

  • Query the MX (Mail Exchange) records for a domain.:

    Output:

    Explanation: This command queries the DNS server for the MX records of the domain 'example.com'. The output shows the priority and the mail server hostname.

How Scaler Transformed Careers in Different Fields

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

Tips

  • Use a specific DNS server by providing its IP address after the domain name or IP address to query.

  • Remember that nslookup doesn't use the /etc/hosts file for name resolution.

Advanced Use Cases of nslookup Command in Linux

  • Perform a reverse DNS lookup.:

    Output:

    Explanation: This command performs a reverse DNS lookup by querying the DNS server for the domain name associated with the IP address '93.184.216.34'. The output displays the resolved domain name.

  • Query the SOA (Start of Authority) record.:

    Output:

    Explanation: This command queries the DNS server for the SOA record of the domain 'example.com'. The output displays various information, such as the primary name server, responsible person, serial number, and various time-related settings.

  • Perform a non-recursive query.:

    Output:

    Explanation: This command performs a non-recursive query for the domain 'example.com'. The output shows the name servers for the domain without providing the IP address associated with the domain.

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Conclusion

  • nslookup is a versatile command-line utility for querying DNS servers.

  • It can resolve domain names to IP addresses and vice versa.

  • Supports querying various DNS record types such as A, AAAA, MX, NS, CNAME, and SOA.

  • Advanced options include reverse DNS lookups, non-recursive queries, and specifying custom DNS servers.