Table of Contents
The nslookup command is a versatile tool used to query Domain Name System (DNS) servers and troubleshoot DNS-related issues. It allows you to check domain IP addresses, verify DNS records, and diagnose network connectivity problems.
STEP 1: Install or Check nslookup
Before using nslookup, ensure it is installed on your system (Linux) or available in Windows. Installing or verifying it first avoids errors and ensures you can query DNS servers reliably.
sudo apt update
sudo apt install dnsutils -y
Linux (RHEL/CentOS):
sudo yum install bind-utils -y
STEP 2: Query a Domain
To check the IP address of a domain, use nslookup. This helps verify whether DNS is correctly resolving a domain name to its IP address on your network.
nslookup example.com
STEP 3: Query Specific DNS Records
Sometimes you need more than just the IP address. You can query MX (mail) or NS (name server) records to get specific DNS information, which is useful for troubleshooting email or server configurations.
nslookup -query=mx example.com # Linux
nslookup -type=mx example.com # Windows
Check NS records:
nslookup -query=ns example.com # Linux
nslookup -type=ns example.com # Windows
STEP 4: Use a Specific DNS Server
If you want to query a domain through a particular DNS server instead of your system’s default, you can specify the server. This ensures consistent results and helps diagnose server-specific issues.
nslookup example.com 1.1.1.1
STEP 5: Interactive Mode
Interactive mode allows you to run multiple queries without typing nslookup each time. This is useful when troubleshooting or examining several records for the same domain.
nslookup # Linux or Windows
Inside interactive mode:
> server 8.8.8.8
> example.com
> set type=mx
> exit
STEP 6: Common Issues and Fixes
When using nslookup, you may encounter errors. Understanding these issues ensures smooth troubleshooting and correct DNS queries.
# Linux
nslookup example.com 8.8.8.8 # Google DNS
nslookup example.com 1.1