Linux Comm Nslookup
[ Linux Command Manual](#)
* * *
nslookup (Name Server Lookup) is a network administration tool for querying Domain Name System (DNS) records. It helps users diagnose and resolve DNS-related issues, and is one of the commonly used command-line tools for Linux system administrators and network engineers.
The main functions of nslookup include:
* Querying the IP address corresponding to a domain name
* Querying the domain name corresponding to an IP address (reverse lookup)
* Querying specific types of DNS records (MX, NS, SOA, etc.)
* Specifying a particular DNS server for queries
* * *
## Basic Syntax
The basic syntax format of the nslookup command is as follows:
nslookup [domain/IP]
### Parameter Description
| Parameter | Description |
| --- | --- |
| domain/IP | The domain name or IP address to query |
| DNS server | Specifies the DNS server to use (optional) |
### Common Options
| Option | Description |
| --- | --- |
| `-type=TYPE` | Specifies the query record type, such as A, MX, NS, etc. |
| `-debug` | Displays debug information |
| `-port=PORT` | Specifies the DNS server port (default 53) |
| `-timeout=SEC` | Sets the query timeout time (seconds) |
| `-retry=NUM` | Sets the number of retry attempts |
* * *
## Usage Examples
### 1. Basic Domain Query
Query the A record of a domain (default):
nslookup example.com
Output example:
Server: 8.8.8.8Address: 8.8.8.8#53Non-authoritative answer:Name: example.com Address: 93.184.216.34
### 2. Specifying a DNS Server for Query
Query using Google's public DNS server (8.8.8.8):
nslookup example.com 8.8.8.8
### 3. Querying Specific Record Types
Query MX records (mail servers):
nslookup -type=MX google.com
Query NS records (name servers):
nslookup -type=NS google.com
Query TXT records:
nslookup -type=TXT google.com
### 4. Reverse DNS Lookup (IP to Domain)
nslookup 8.8.8.8
### 5. Interactive Mode
Enter nslookup without parameters to enter interactive mode:
## Example
nslookup
>set type=MX
> google.com
> server 8.8.4.4
> example.com
>exit
* * *
## Common DNS Record Types
| Record Type | Description | Example Command |
| --- | --- | --- |
| A | IPv4 address record | `nslookup -type=A example.com` |
| AAAA | IPv6 address record | `nslookup -type=AAAA example.com` |
| MX | Mail exchange record | `nslookup -type=MX example.com` |
| NS | Name server record | `nslookup -type=NS example.com` |
| CNAME | Canonical name record | `nslookup -type=CNAME www.example.com` |
| TXT | Text record | `nslookup -type=TXT example.com` |
| SOA | Start of authority record | `nslookup -type=SOA example.com` |
* * *
## Advanced Usage
### 1. Debug Mode
nslookup -debug example.com
### 2. Querying DNS Root Servers
nslookup -type=NS .
### 3. Querying a Specific Port
nslookup -port=8053 example.com dns-server.example.com
### 4. Setting Timeout and Retry
nslookup -timeout=10 -retry=3 example.com
* * *
## Common Problem Resolution
### 1. Query Has No Response
Possible causes:
* Network connection issues
* DNS server unavailable
* Firewall blocking DNS queries (port 53)
Solutions:
## Example
# Check network connection
ping 8.8.8.8
# Try another DNS server
nslookup example.com 8.8.8.8
### 2. What Does "Non-authoritative answer" Mean?
It indicates that the returned result comes from a DNS cache rather than an authoritative DNS server. To obtain an authoritative answer, you need to query the authoritative DNS server for that domain.
### 3. How to Query the Authoritative DNS Server for a Domain?
nslookup -type=NS example.com
* * *
## Alternative Tools
Although nslookup is still widely used, modern Linux systems prefer to recommend `dig` or `host` commands:
1. **dig** - A more powerful DNS query tool
dig example.com
2. **host** - A simpler DNS query tool
host example.com
* * *
## Summary
nslookup is a simple and practical DNS query tool. Through this tutorial, you should be able to:
1. Understand the basic usage and common options of nslookup
2. Query various types of DNS records
3. Diagnose basic DNS-related issues
4. Understand the differences between nslookup and other DNS tools
The best way to master nslookup is through practice. Try querying websites you frequently visit, or your organization's domain name servers, and observe the results returned by different types of DNS records.
* * Linux Command Manual](#)
YouTip