nslookup command snippets

Copy-paste-ready nslookup commands for DNS lookups, reverse queries, record type checks, and debug output.

Copy-paste-ready nslookup commands for common DNS lookup tasks.

Look Up a Domain IP Address with nslookup

nslookup queries the default DNS resolver and returns the A record (IPv4 address) for the specified domain.

nslookup example.com

Perform a Reverse DNS Lookup with nslookup

nslookup resolves an IP address to its associated domain name by querying the PTR record in the in-addr.arpa zone.

nslookup 203.0.113.50

Query the A Record with nslookup

nslookup retrieves the IPv4 address mapped to a domain name using the -type=a flag.

nslookup -type=a example.com

Query MX Records with nslookup

nslookup returns the mail exchange (MX) servers responsible for handling email delivery for the specified domain.

nslookup -type=mx example.com

Query NS Records with nslookup

nslookup lists the authoritative nameservers for a domain by querying the NS record type.

nslookup -type=ns example.com

Query SOA Records with nslookup

nslookup retrieves the Start of Authority (SOA) record, which contains the primary nameserver, admin contact, zone serial number, and refresh intervals.

nslookup -type=soa example.com

Query TXT Records with nslookup

nslookup displays TXT records that store SPF policies, DKIM keys, and domain verification tokens.

nslookup -type=txt example.com

Query All DNS Records with nslookup

nslookup retrieves all available DNS record types for a domain using the -type=any flag. Some DNS servers restrict this query type.

nslookup -type=any example.com

Query a Specific DNS Server with nslookup

nslookup sends the query to a specified DNS server instead of the system's default resolver. This example queries Google Public DNS (8.8.8.8).

nslookup example.com 8.8.8.8

Enable Debug Output with nslookup

nslookup displays full DNS response details -- including TTL values, query sections, and authority records -- when the -debug flag is set.

nslookup -debug example.com

Set a Custom Timeout with nslookup

nslookup waits the specified number of seconds for a DNS server response before timing out. The default timeout is 5 seconds.

nslookup -timeout=10 example.com

Query CNAME Records with nslookup

nslookup returns the canonical name (alias) record for a domain, showing which domain name the alias resolves to.

nslookup -type=cname www.example.com