Overview
nslookup (name server lookup) is a tool used to obtain IP addresses for domain names or domain names for IP addresses through DNS queries. This command was originally part of the `BIND (Berkeley Internet Name Domain)` package, but due to functional limitations and unpredictable behavior, it is now officially deprecated and has been replaced by more stable tools such as `dig` or `host`. However, it is still included by default in many systems and is sometimes used for simple DNS information checks.
Key Features
The main features of the nslookup command are as follows:
- Queries the IP address (A record) for a domain name.
- Queries the domain name (PTR record) for an IP address.
- Supports interactive mode to execute multiple queries consecutively.
- Simpler output format compared to `dig`.
Differences from dig
nslookup has simpler functionality than dig and is rarely used nowadays.
- nslookup: An outdated tool that is not recommended for use. Difficult to use in scripts due to unpredictable behavior.
- dig: The most widely used modern DNS query tool. Provides detailed and structured output, and allows for precise queries through various options.
Key Options
nslookup is primarily used in interactive mode with the `set` command, or in non-interactive mode with arguments.
1) Execution Options
2) Interactive Mode
Generated command:
Try combining the commands.
Description:
`nslookup` Executes the command.
Combine the above options to virtually execute commands with AI.
Usage Examples
Learn the functions of the nslookup command through various usage examples.
Basic Domain Query
nslookup google.com
Outputs the IP address of `google.com` and the name server information that responded to the query.
Query Mail Server (MX) Record
nslookup -type=MX gmail.com
Queries the mail server information for `gmail.com`.
Query with Specific Name Server
nslookup naver.com 8.8.8.8
Queries information for `naver.com` using Google's DNS server (`8.8.8.8`).
Using Interactive Mode
nslookup
> server 8.8.8.8
> set type=MX
> naver.com
> exit
Enters interactive mode to execute multiple queries consecutively.
Installation
nslookup is typically included by default as part of the `bind-utils` or `dnsutils` package in most Linux distributions. If not present, you can install it using the following commands.
Debian/Ubuntu
sudo apt update
sudo apt install -y dnsutils
RHEL/CentOS/Fedora
sudo dnf install -y bind-utils
Tips & Cautions
Here are some points to note when using the nslookup command.
Tips
- `nslookup` is no longer recommended for use. For DNS troubleshooting, it's better to use `dig`, and for simple queries, `host`.
- The interactive mode of `nslookup` has the disadvantage of being difficult to automate in scripts.
- If `nslookup` does not respond, there might be an issue with the DNS server configured in your system's `/etc/resolv.conf` file or a network connectivity problem.