nslookup
nslookup
nslookup
is a command-line tool used for querying the Domain Name System (DNS) to obtain domain name or IP address mapping information. It is widely used for network troubleshooting and is available on most operating systems, including Linux, macOS, and Windows.
Usage
nslookup [options] [domain-name | IP-address] [DNS-server]
domain-name | IP-address
: The domain name or IP address to query.DNS-server
: The DNS server to use for the query. If not specified, the default DNS server configured in the system will be used.options
: Additional command-line options to control the behavior ofnslookup
.
Common Options
-type=TYPE
or-q=TYPE
: Specifies the type of DNS record to query (e.g., A, MX, NS, etc.).-timeout=NUMBER
: Sets the timeout interval for the request in seconds.-retry=NUMBER
: Sets the number of retries for the request.-debug
: Enables debugging mode to show detailed information about the request and response.
Examples
Basic Query
To query the A record for
example.com
:nslookup example.com
Output:
Server: 8.8.8.8 Address: 8.8.8.8#53 Non-authoritative answer: Name: example.com Address: 93.184.216.34
Query a Specific DNS Server
To query the DNS server at
8.8.8.8
for the A record ofexample.com
:nslookup example.com 8.8.8.8
Query for a Specific Record Type
To query the MX records for
example.com
:nslookup -query=MX example.com
Output:
Server: 8.8.8.8 Address: 8.8.8.8#53 Non-authoritative answer: example.com mail exchanger = 10 mail.example.com.
Reverse DNS Lookup
To perform a reverse DNS lookup for the IP address
192.0.2.1
:nslookup 192.0.2.1
Output:
Server: 8.8.8.8 Address: 8.8.8.8#53 Non-authoritative answer: 1.2.0.192.in-addr.arpa name = example.com.
Debugging Mode
To enable debugging mode for more detailed output:
nslookup -debug example.com
Benefits of Using nslookup
nslookup
Simplicity: Easy to use for basic DNS queries.
Availability: Pre-installed on most operating systems.
Flexibility: Supports querying different types of DNS records and specific DNS servers.
Debugging: Provides detailed debugging information for advanced troubleshooting.
Use Cases
Example 1: Verify Mail Server Configuration
To check the mail exchange (MX) records for a domain:
nslookup -type=MX example.com
Example 2: Check Name Server Records
To list the authoritative name servers for a domain:
nslookup -type=NS example.com
Example 3: Reverse Lookup
To verify the hostname associated with an IP address:
nslookup 93.184.216.34
Conclusion
nslookup
is a versatile tool for performing DNS lookups and troubleshooting DNS-related issues. It offers a straightforward interface for querying various types of DNS records and can be used to check domain name resolutions, mail server configurations, and more. Whether you are a network administrator or a developer, nslookup
provides essential functionality for managing and diagnosing DNS issues.
help
nslookup [options] hostname [server]
Options:
-?, --help Print this help message.
-a, --all List all records.
-c, --cache Use the local cache.
-d, --debug Print debugging information.
-f, --family Set address family to AF_INET or AF_INET6.
-i, --info List additional information about records.
-k, --keep-query Continue to query until the answer has expired.
-n, --no-cache Do not use the local cache.
-p, --port Set the port number to use for queries.
-r, --recurse Recursively query for all records.
-s, --server Specify the name server to use.
-t, --type Specify the type of record to query.
-v, --verbose Print verbose output.
-w, --timeout Set the timeout value in seconds.
For more information, see the nslookup man page.
Last updated