nslookup queries DNS servers for domain name resolution and is useful for inspecting basic DNS behavior. Though older and less flexible than dig, it’s still available on many systems and familiar to network admins.
It’s part of the dnsutils or bind-utils packages:
sudo apt install dnsutils
sudo yum install bind-utilsnslookup example.com
Returns the IP address and DNS server information.
nslookup example.com 8.8.8.8
nslookup -query=MX example.com
nslookup -type=NS example.com
host is a compact DNS lookup tool that gives concise output for common record types. It’s simpler than nslookup and well-suited for scripting and automation.
Also included in dnsutils:
sudo apt install dnsutilshost example.com
Displays IPv4 or IPv6 addresses directly.
host -t MX example.com
host -t NS example.com
host -t TXT example.com
host example.com 8.8.8.8
host 8.8.8.8
| Feature | nslookup | host |
|---|---|---|
| Output format | Verbose | Concise |
| Supports multiple record types | ✅ | ✅ |
| Script-friendly | ❌ | ✅ |
| Specify DNS server | ✅ | ✅ |
nslookup and host offer simple, fast methods for DNS diagnostics in Linux. While dig provides more detail and flexibility, these two tools are valuable for quick checks, scripting, and basic troubleshooting.