Host - Simple DNS Lookup Tool
Overview
host is a simple DNS lookup utility that provides clean, easy-to-read output for DNS queries. It’s designed to be more user-friendly than dig and more straightforward than nslookup, making it ideal for quick DNS lookups and basic troubleshooting tasks.
Basic Syntax
host [options] hostname [server]
host [options] IP_address [server]
Essential Commands
Basic DNS Lookups
# Look up A and AAAA records (IPv4 and IPv6)
host google.com
<button @click='copyCommand("host google.com")' class="copy-btn">Copy
# Reverse DNS lookup (IP to domain)
host 8.8.8.8
<button @click='copyCommand("host 8.8.8.8")' class="copy-btn">Copy
# IPv6 reverse lookup
host 2001:4860:4860::8888
<button @click='copyCommand("host 2001:4860:4860::8888")' class="copy-btn">Copy
# Using specific DNS server
host google.com 8.8.8.8
<button @click='copyCommand("host google.com 8.8.8.8")' class="copy-btn">Copy
Record Type Queries
# A record (IPv4 address)
host -t A google.com
<button @click='copyCommand("host -t A google.com")' class="copy-btn">Copy
# AAAA record (IPv6 address)
host -t AAAA google.com
<button @click='copyCommand("host -t AAAA google.com")' class="copy-btn">Copy
# MX record (Mail Exchange)
host -t MX google.com
<button @click='copyCommand("host -t MX google.com")' class="copy-btn">Copy
# NS record (Name Server)
host -t NS google.com
<button @click='copyCommand("host -t NS google.com")' class="copy-btn">Copy
# TXT record (Text records)
host -t TXT google.com
<button @click='copyCommand("host -t TXT google.com")' class="copy-btn">Copy
# CNAME record (Canonical Name)
host -t CNAME www.google.com
<button @click='copyCommand("host -t CNAME www.google.com")' class="copy-btn">Copy
# SOA record (Start of Authority)
host -t SOA google.com
<button @click='copyCommand("host -t SOA google.com")' class="copy-btn">Copy
# PTR record (Pointer for reverse lookup)
host -t PTR 8.8.8.8
<button @click='copyCommand("host -t PTR 8.8.8.8")' class="copy-btn">Copy
# SRV record (Service record)
host -t SRV _sip._tcp.example.com
<button @click='copyCommand("host -t SRV _sip._tcp.example.com")' class="copy-btn">Copy
Advanced Options
Verbose and Debug Output
# Verbose output (equivalent to -a)
host -v google.com
<button @click='copyCommand("host -v google.com")' class="copy-btn">Copy
# All records (ANY query type)
host -a google.com
<button @click='copyCommand("host -a google.com")' class="copy-btn">Copy
# Debug output
host -d google.com
<button @click='copyCommand("host -d google.com")' class="copy-btn">Copy
Timeout and Connection Options
# Set timeout (5 seconds)
host -W 5 google.com
<button @click='copyCommand("host -W 5 google.com")' class="copy-btn">Copy
# Wait indefinitely for reply
host -w google.com
<button @click='copyCommand("host -w google.com")' class="copy-btn">Copy
# Use TCP instead of UDP
host -T google.com
<button @click='copyCommand("host -T google.com")' class="copy-btn">Copy
# Set number of UDP retries
host -R 3 google.com
<button @click='copyCommand("host -R 3 google.com")' class="copy-btn">Copy
Query Behavior Options
# Non-recursive query
host -r google.com
<button @click='copyCommand("host -r google.com")' class="copy-btn">Copy
# Specify query class (default: IN)
host -c IN google.com
<button @click='copyCommand("host -c IN google.com")' class="copy-btn">Copy
# Show SOA records from all authoritative servers
host -C example.com
<button @click='copyCommand("host -C example.com")' class="copy-btn">Copy
# Zone transfer (list mode)
host -l example.com
<button @click='copyCommand("host -l example.com")' class="copy-btn">Copy
Popular DNS Servers
Using Different DNS Providers
# Google DNS
host google.com 8.8.8.8
<button @click='copyCommand("host google.com 8.8.8.8")' class="copy-btn">Copy
# Cloudflare DNS
host google.com 1.1.1.1
<button @click='copyCommand("host google.com 1.1.1.1")' class="copy-btn">Copy
# OpenDNS
host google.com 208.67.222.222
<button @click='copyCommand("host google.com 208.67.222.222")' class="copy-btn">Copy
# Quad9 DNS
host google.com 9.9.9.9
<button @click='copyCommand("host google.com 9.9.9.9")' class="copy-btn">Copy
Common Use Cases
Email Server Troubleshooting
# Check MX records for email routing
host -t MX example.com
<button @click='copyCommand("host -t MX example.com")' class="copy-btn">Copy
# Verify mail server IP
host mail.example.com
<button @click='copyCommand("host mail.example.com")' class="copy-btn">Copy
# Check multiple mail servers
host -t MX gmail.com yahoo.com outlook.com
<button @click='copyCommand("host -t MX gmail.com yahoo.com outlook.com")' class="copy-btn">Copy
Domain Verification
# Check TXT records for domain verification
host -t TXT example.com
<button @click='copyCommand("host -t TXT example.com")' class="copy-btn">Copy
# Verify SPF records
host -t TXT example.com|grep "v=spf1"
<button @click='copyCommand("host -t TXT example.com|grep \"v=spf1\"")' class="copy-btn">Copy
# Check DKIM records
host -t TXT default._domainkey.example.com
<button @click='copyCommand("host -t TXT default._domainkey.example.com")' class="copy-btn">Copy
Network Diagnostics
# Check authoritative name servers
host -t NS example.com
<button @click='copyCommand("host -t NS example.com")' class="copy-btn">Copy
# Verify domain authority information
host -t SOA example.com
<button @click='copyCommand("host -t SOA example.com")' class="copy-btn">Copy
# Check CNAME aliases
host -t CNAME www.example.com
<button @click='copyCommand("host -t CNAME www.example.com")' class="copy-btn">Copy
# Comprehensive domain analysis
host -a example.com
<button @click='copyCommand("host -a example.com")' class="copy-btn">Copy
Reverse DNS Lookups
# Check hostname for IP
host 192.168.1.1
<button @click='copyCommand("host 192.168.1.1")' class="copy-btn">Copy
# Verify server identity
host 208.67.222.222
<button @click='copyCommand("host 208.67.222.222")' class="copy-btn">Copy
# IPv6 reverse lookup
host 2001:4860:4860::8844
<button @click='copyCommand("host 2001:4860:4860::8844")' class="copy-btn">Copy
Troubleshooting Commands
Debug and Verbose Queries
# Debug mode with specific record type
host -d -t A google.com
<button @click='copyCommand("host -d -t A google.com")' class="copy-btn">Copy
# Verbose TCP query
host -v -T google.com
<button @click='copyCommand("host -v -T google.com")' class="copy-btn">Copy
# Non-recursive NS query
host -r -t NS google.com
<button @click='copyCommand("host -r -t NS google.com")' class="copy-btn">Copy
# Extended timeout with MX query
host -W 10 -t MX example.com
<button @click='copyCommand("host -W 10 -t MX example.com")' class="copy-btn">Copy
Command Options Reference
| Option | Description |
|---|---|
-a | Equivalent to -v and -t ANY |
-C | Show SOA records from all authoritative servers |
-c class | Specify query class (default: IN) |
-d | Enable debug output |
-l | List mode (zone transfer) |
-n | Use IP6.INT domain for IPv6 reverse lookups |
-N ndots | Set number of dots for absolute names |
-r | Make non-recursive queries |
-R retries | Set number of UDP retries |
-t type | Specify query type (A, AAAA, MX, NS, etc.) |
-T | Use TCP connection |
-v | Verbose output |
-W seconds | Set timeout in seconds |
-w | Wait indefinitely for reply |
Record Types
| Type | Description | Example |
|---|---|---|
| A | IPv4 address | host -t A google.com |
| AAAA | IPv6 address | host -t AAAA google.com |
| CNAME | Canonical name | host -t CNAME www.google.com |
| MX | Mail exchange | host -t MX google.com |
| NS | Name server | host -t NS google.com |
| PTR | Pointer (reverse) | host -t PTR 8.8.8.8 |
| SOA | Start of authority | host -t SOA google.com |
| SRV | Service record | host -t SRV _sip._tcp.example.com |
| TXT | Text record | host -t TXT google.com |
| ANY | All records | host -a google.com |
Installation
Linux (Ubuntu/Debian)
sudo apt-get install dnsutils
Linux (CentOS/RHEL/Fedora)
sudo yum install bind-utils
# or
sudo dnf install bind-utils
macOS
host comes pre-installed with macOS.
Windows
Use Windows Subsystem for Linux (WSL) or install via package managers like Chocolatey.
Tips and Best Practices
- Clean output: host provides cleaner, more readable output than dig
- Quick lookups: Ideal for simple DNS queries and basic troubleshooting
- Multiple queries: Can query multiple domains in a single command
- Reverse lookups: Automatically detects IP addresses and performs reverse lookups
- Timeout settings: Use
-Woption for slow or unreliable networks - TCP queries: Use
-Tfor large responses or when UDP is blocked - Combine with other tools: Use alongside dig and nslookup for comprehensive analysis
Common Error Messages
| Error | Meaning |
|---|---|
Host not found | Domain doesn’t exist (NXDOMAIN) |
No address associated with hostname | No A/AAAA records found |
Connection timed out | DNS server unreachable |
Server failure | DNS server error (SERVFAIL) |
Query refused | DNS server refused the query |
Related Commands
dig- More detailed DNS lookup tool with extensive optionsnslookup- Interactive DNS lookup utilityping- Test network connectivity and resolve hostnamestraceroute- Trace network path to destinationwhois- Domain registration and ownership information