What is nslookup?
Learn what nslookup is, how to query DNS records like A and MX, and how it helps diagnose DNS issues — with interview Q&A.
Expected Interview Answer
nslookup is a command-line tool that queries DNS servers to resolve a domain name to its IP address, or an IP address back to a domain name, and can also fetch specific DNS record types such as MX or NS records.
By default, nslookup sends a query to the system’s configured DNS resolver and returns the A (or AAAA) record for the given hostname, showing both the resolver used and the resulting address. It can also be pointed at a specific DNS server by passing it as a second argument, which is useful for comparing what different resolvers return, such as checking whether a DNS change has propagated. Adding "-type=" lets a user request other record types, such as MX for mail servers, NS for authoritative name servers, or TXT for text records like SPF entries. nslookup has an interactive mode as well, entered by running it with no arguments, where multiple queries can be issued in the same session; newer tools like “dig” offer more detailed output for the same underlying purpose.
- Resolves a hostname to an IP address (and vice versa)
- Can query a specific DNS server instead of the default resolver
- Fetches specific record types like MX, NS, and TXT
- Helps diagnose DNS propagation and misconfiguration issues
AI Mentor Explanation
nslookup is like asking the ground’s information desk “which stadium hosts the team called Falcons?” and getting back the exact address, rather than driving around the city guessing. You can also ask a different information desk in another city to see if they have the same answer, which mirrors querying a different DNS server. Asking for the team’s captain instead of its stadium is like requesting an MX record instead of an A record — same desk, different piece of information. nslookup performs this same directed lookup against a naming service instead of a stadium directory.
Step-by-Step Explanation
Step 1
Send the query
nslookup sends a hostname (or IP) lookup to the configured or specified DNS server.
Step 2
Server responds
The DNS server returns the matching record, such as an A record with the IP address.
Step 3
Optional record type
Use "-type=MX", "-type=NS", or similar to request a specific record type instead of A/AAAA.
Step 4
Compare resolvers
Point nslookup at a different DNS server as a second argument to check for propagation differences.
What Interviewer Expects
- Explains nslookup resolves hostnames to IPs (and reverse lookups)
- Knows how to query a specific DNS server and specific record types
- Can describe a use case like checking DNS propagation or an MX record
- Aware that dig offers more detailed output for similar purposes
Common Mistakes
- Confusing nslookup with a tool for testing HTTP reachability
- Not knowing how to query a non-default DNS server
- Forgetting that cached results can mask a recent DNS change
- Assuming nslookup and dig always return identically formatted output
Best Answer (HR Friendly)
“nslookup is a command-line tool for asking a DNS server “what IP address does this domain point to?” or the reverse. I use it when I need to quickly verify that a domain resolves correctly, check a specific DNS server’s answer, or confirm that a DNS change like an MX record update has actually taken effect.”
Code Example
# Basic A record lookup using the default resolver
nslookup example.com
# Query a specific DNS server (Google’s public resolver)
nslookup example.com 8.8.8.8
# Look up MX (mail exchange) records
nslookup -type=MX example.com
# Example output
# Server: 8.8.8.8
# Address: 8.8.8.8#53
# Name: example.com
# Address: 93.184.216.34Follow-up Questions
- What is the difference between nslookup and dig?
- How would you check whether a DNS change has propagated?
- What does an MX record do compared to an A record?
- How does a reverse DNS lookup with nslookup work?
MCQ Practice
1. What does nslookup primarily do?
nslookup sends queries to a DNS server to resolve hostnames to IP addresses or vice versa.
2. Which flag requests a specific DNS record type in nslookup?
"-type=" (e.g., -type=MX) tells nslookup which DNS record type to request.
3. How do you query a non-default DNS server with nslookup?
Running “nslookup hostname dns-server-ip” directs the query at that specific DNS server.
Flash Cards
What is nslookup? — A command-line tool that queries DNS to resolve hostnames to IPs and vice versa.
How to query a specific DNS server? — Pass it as a second argument: nslookup hostname dns-server-ip.
How to look up MX records? — Use nslookup -type=MX hostname.
What is a common modern alternative? — dig, which provides more detailed DNS query output.