# nslookup
## What is nslookup
Nslookup stands for name server lookup. It is a command-line tool used to query DNS servers to find the IP address associated with a domain name or to find the domain name associated with an IP address. It is available on Windows, Linux, and macOS. Nslookup is one of the primary tools for diagnosing DNS problems and for investigating DNS configurations.
## Basic Usage
Running nslookup followed by a domain name queries the default DNS server configured on the system and returns the IP address associated with that domain. The output shows the server that was queried, its IP address, the name that was queried, and the IP address returned. If the domain resolves to multiple IP addresses, all addresses are shown. Running nslookup followed by an IP address performs a reverse DNS lookup, returning the domain name associated with that IP address.
## Interactive Mode
Running nslookup without any arguments enters interactive mode where multiple queries can be performed. In interactive mode you can change settings such as the DNS server to query, the record type to look up, and other options. The set type command changes the record type being queried. Set type equals mx queries for mail exchange records. Set type equals ns queries for name server records. Set type equals txt queries for text records.
## Querying Different DNS Servers
By default nslookup queries the DNS server configured in the system network settings. You can query a specific DNS server by specifying it after the domain name. For example nslookup google.com 8.8.8.8 queries Google's public DNS server. This is useful for comparing the response from different DNS servers or for testing a DNS server that has not yet been made the default.
## Diagnosing DNS Problems
Nslookup is used to verify that DNS resolution is working correctly. If a user cannot access a website, running nslookup on the domain name reveals whether DNS can resolve the name. If nslookup fails, the problem is with DNS resolution. If nslookup succeeds but the website is still inaccessible, the problem is elsewhere such as a firewall, routing issue, or the web server itself. Comparing results from different DNS servers can reveal whether a DNS record has propagated correctly after being changed.
## dig Command
On Linux and macOS the dig command, which stands for domain information groper, provides similar functionality to nslookup but with more detailed output and more options. Network engineers often prefer dig over nslookup because of its clearer output format and extensive query options.Back to Subject