What is `nslookup`?

The `nslookup` (Name Server Lookup) command is a powerful tool for querying the Domain Name System (DNS) to find the IP address associated with a domain name. It can also perform reverse lookups to find the domain name associated with an IP address. It's an essential command for any student learning about how the internet translates human-readable domain names into machine-readable IP addresses.

How to Use It

The most basic use of `nslookup` is to find the IP address for a specific domain. You can do this by typing the command followed by the domain name in your terminal or command prompt.

Example Usage

nslookup google.com

This command contacts your configured DNS server and asks it for the IP address records (specifically A for IPv4 and AAAA for IPv6) associated with `google.com`.

Understanding the Output

The output shows you two main pieces of information: the server that answered your query, and the answer itself.

  • Server: This is the address of the DNS server that your system is configured to use.
  • Address: The IP address of that DNS server.
  • Non-authoritative answer: This means the DNS server doesn't host the original records itself but has a cached copy. This is very common.
  • Name and Addresses: This is the answer to your query, showing the domain name and its corresponding IP addresses.

Example Output

Server:  dns.google
Address:  8.8.8.8

Non-authoritative answer:
Name:    google.com
Addresses: 2404:6800:4007:828::200e
         142.250.196.238
                    

Using `nslookup` is a fundamental skill for troubleshooting issues like "why can't I access this website?" as it helps you confirm if the domain is resolving to the correct IP address.