Understanding Basic DNS Lookup:
- A records: IPv4 addresses shown with "has address"
- AAAA records: IPv6 addresses shown with "has IPv6 address"
- Multiple IPs: Large sites often have multiple IPs for load balancing
- Mail records: MX records automatically shown for many domains
- Default behavior: Queries for A and AAAA records by default
- System resolver: Uses /etc/resolv.conf to determine DNS servers to query
- Clean output: More readable than nslookup for simple queries
- Quick check: Fastest way to verify domain resolves correctly
Reverse DNS Mechanics:
- PTR records: Map IP addresses back to hostnames
- in-addr.arpa: Special domain for IPv4 reverse lookups (reversed octets)
- ip6.arpa: Used for IPv6 reverse lookups
- Not always present: Many IPs don't have reverse DNS configured
- Email servers: Often require valid reverse DNS for spam prevention
- Private IPs: RFC 1918 addresses (192.168.x.x, 10.x.x.x) usually don't resolve
- Verification: Useful for identifying server owners or ISP information
- Security: Can help identify suspicious connections in logs
DNS Record Types Explained:
- MX (Mail Exchange): Lists mail servers for domain, with priority numbers (lower = higher priority)
- NS (Name Server): Authoritative DNS servers for the domain
- TXT (Text): Arbitrary text data; used for SPF, DKIM, domain verification, etc.
- SOA (Start of Authority): Primary nameserver, contact email, serial number, refresh timers
- AAAA: IPv6 addresses (quad-A record)
- CNAME: Canonical name (alias pointing to another domain)
- PTR: Pointer for reverse DNS lookups
- A: IPv4 address (can query explicitly with -t A)
Querying Specific DNS Servers:
- Syntax: host domain server_ip
- Server information: Shows which DNS server was queried
- Port 53: DNS queries use UDP/TCP port 53
- Google DNS: 8.8.8.8 and 8.8.4.4 (public, reliable)
- Cloudflare DNS: 1.1.1.1 and 1.0.0.1 (privacy-focused, fast)
- OpenDNS: 208.67.222.222 and 208.67.220.220 (content filtering available)
- Testing: Useful for comparing results between different DNS servers
- Troubleshooting: Helps identify DNS propagation issues or local resolver problems
Verbose Output Components:
- Header section: Query ID, status codes, flags
- Flags: qr (query response), rd (recursion desired), ra (recursion available)
- QUERY count: Number of questions asked
- ANSWER count: Number of answers received
- AUTHORITY: Number of authority records (NS records)
- ADDITIONAL: Extra helpful records
- TTL value: 86400 seconds = 24 hours cache time
- Response time: Shows latency (25 ms in example)
- Source server: Which DNS server provided the response
Comprehensive Record Query:
- ANY query: Requests all record types (though some servers limit this)
- Complete picture: See all DNS configuration at once
- A and AAAA: Both IPv4 and IPv6 addresses
- NS records: Authoritative name servers for domain
- SOA record: Zone authority information and serial number
- TXT records: Text data including SPF, verification tokens
- Server limitations: Some DNS servers restrict ANY queries for security
- Alternative: If -a returns limited results, query each record type separately
Timeout Configuration:
- -W seconds: Maximum time to wait for response
- Default timeout: Usually 5 seconds if not specified
- Network issues: Helps identify if problem is slow DNS or network connectivity
- Script automation: Prevents scripts from hanging on slow queries
- Fast failure: Lower timeout forces quick failure for unreachable servers
- Time command: Use with time to measure actual query duration
- Production monitoring: Set appropriate timeouts for health checks
- Retry behavior: host may retry if first attempt times out
Recursive vs Non-Recursive Queries:
- Recursive (default): DNS server follows referrals to get final answer
- Non-recursive (-r): Server only returns what it knows directly
- Authoritative check: Test if server is authoritative for domain
- Caching behavior: Non-recursive bypasses cache in some cases
- Root servers: Root DNS servers only respond to non-recursive queries
- Testing setup: Verify authoritative nameservers configured correctly
- Referral chains: Without recursion, may get NS referrals instead of answers
- Performance: Recursive queries do more work but give complete answers
Scripting with host:
- Exit codes: 0 = success, non-zero = failure (use with if statements)
- Output parsing: Use grep, awk, cut to extract specific information
- Redirect stderr: 2>&1 captures errors for cleaner output
- Null output: > /dev/null hides output when only checking success
- Batch processing: Loop through domain lists from files
- Monitoring: Check DNS health periodically with cron jobs
- Error handling: Always check exit codes and provide feedback
- Timeout integration: Add -W flag to prevent script hangs
DNSSEC Record Types:
- DNSKEY: Public keys used to verify DNS signatures
- DS (Delegation Signer): Hash of child zone's DNSKEY, stored in parent zone
- RRSIG: Cryptographic signature of DNS records (not shown by default)
- Security enhancement: DNSSEC prevents DNS spoofing and cache poisoning
- Chain of trust: DS records link parent and child zones securely
- KSK vs ZSK: Key-Signing Key (257) and Zone-Signing Key (256)
- Not universal: Many domains don't implement DNSSEC yet
- Validation: Requires DNSSEC-aware resolver to actually validate