Windows nslookup Command
Windows nslookup Command
The nslookup
command in Windows is used for querying the Domain Name System (DNS) to obtain domain name or IP address mapping information.
Syntax
The general syntax of the command are as follows:
/> nslookup [hostname] [DNS_server]
nslookup Command-Line Flags
Flag | Description |
---|---|
/? |
Displays help information. |
-d2 |
Enables extensive debugging output. |
-debug |
Displays debugging information. |
-timeout=<seconds> |
Specifies the query timeout duration. Default is 2 seconds. |
-retry=<number> |
Sets the number of retries before giving up. Default is 4. |
-type=<record> |
Specifies the DNS record type to query (e.g., A, MX, NS, TXT, CNAME). |
-querytype=<record> |
Same as -type , defines the DNS record type to query. |
-class=<class> |
Specifies the query class (IN, CH, HS). Default is IN (Internet). |
-server=<address> |
Specifies the DNS server to use for the lookup. |
-port=<number> |
Specifies the port number for DNS queries (default is 53). |
-vc |
Forces the use of TCP instead of UDP for queries. |
-norecurse |
Disables recursion (queries only the specified DNS server, without forwarding requests). |
-retry=<number> |
Sets the number of retries. |
-timeout=<seconds> |
Sets the timeout for the query response. |
-exit |
Exits nslookup interactive mode. |
Examples
Basic Domain Name Lookup
nslookup example.com
Resolves the IP address of example.com
Reverse DNS Lookup (Find Domain from IP)
/> nslookup 8.8.8.8
This command returns the domain name associated with the IP address 8.8.8.8
.
Query a Specific DNS Server
/> nslookup example.com 8.8.8.8
Uses Google’s public DNS server (8.8.8.8) to resolve example.com
.
Find Mail Servers (MX Records)
/> nslookup -query=mx example.com
Displays mail exchange (MX) records for example.com
Find Name Server Records (NS Records)
/> nslookup -query=ns example.com
Shows the authoritative name servers for example.com
.
Find Start of Authority Record (SOA Record)
/> nslookup -query=soa example.com
Displays the SOA record for example.com
.
Find All Available DNS Records
/> nslookup -query=any example.com
Retrieves all available DNS records.
Interactive Mode
/> nslookup
Enter interactive mode where multiple lookups can be performed.
> set type=mx
> example.com
Change Default DNS Server
nslookup
> server 8.8.8.8
Uses Google’s DNS for subsequent queries.
Debug Mode for More Details
/> nslookup -debug example.com
Provides detailed output for troubleshooting.
Uses
- Diagnosing DNS resolution issues.
- Checking if a domain’s DNS records are correctly configured.
- Finding mail server settings for a domain.
- Testing DNS propagation after changes.