Overview
nslookup is used to check the mapping between domain names and IP addresses, or to query specific DNS records (MX, NS, A, etc.). It is primarily used for DNS troubleshooting and network diagnostics.
Key Features
- Query domain-to-IP address mapping
- Query specific DNS records (A, MX, NS, etc.)
- Query a specific DNS server
- Supports interactive/non-interactive modes
Key Options
In addition to command-line options, nslookup allows setting various options through the `set` command in interactive mode.
Query Type and Debugging
Specify Server
Generated command:
Try combining the commands.
Description:
`nslookup` Executes the command.
Combine the above options to virtually execute commands with AI.
Usage Examples
Various usage examples of the nslookup command.
Basic Domain Information Lookup
nslookup example.com
Looks up the IP address for a specified domain.
Lookup Using a Specific DNS Server
nslookup example.com 8.8.8.8
Looks up domain information using Google Public DNS (8.8.8.8).
Query Mail Exchanger (MX) Records
nslookup -type=mx example.com
Looks up the mail server information for a domain.
Entering and Using Interactive Mode
nslookup
> server 8.8.8.8
> example.com
> exit
Runs nslookup in interactive mode and then performs queries using internal commands.
Reverse Lookup: IP Address to Domain Name
nslookup 192.0.2.1
Looks up the domain name corresponding to an IP address.
Installation
nslookup is usually included by default in most Linux distributions or provided as part of a DNS utilities package. If it's not installed, you can install it using the following commands:
Debian/Ubuntu
sudo apt update && sudo apt install dnsutils
Installs the dnsutils package using the apt package manager.
CentOS/RHEL/Fedora
sudo yum install bind-utils
# or
sudo dnf install bind-utils
Installs the bind-utils package using the yum or dnf package manager.
Tips & Notes
Useful tips and points to note when using nslookup.
Consider Using `dig`
While nslookup is still widely used, the `dig` command offers more powerful and detailed DNS information and is better suited for scripting. It is recommended to use `dig` alongside nslookup for DNS troubleshooting.
- `dig` supports more DNS record types
- `dig` provides detailed response information
- `dig` has an output format that is easier to parse in scripts
Utilize Interactive Mode
Interactive mode is convenient for performing multiple queries. You can type `help` in interactive mode to see available internal commands.
- `set type=mx` (Set to query MX records)
- `server 1.1.1.1` (Change the DNS server to query)
- `exit` (Exit interactive mode)