Mastering the `host` DNS Lookup Utility: A Comprehensive Guide
If you’ve ever needed to:
Check if a domain resolves to an IP address,
Find a company’s mail servers,
Verify a domain’s DNS security (DNSSEC), or
Perform a reverse lookup (IP → domain),
host is your go-to tool. It’s part of the BIND (Berkeley Internet Name Domain) suite—the most widely used DNS software on the internet—and comes pre-installed on nearly all Linux distributions, macOS, and Unix-like systems.
Unlike more complex tools like dig, host prioritizes simplicity and focus. It’s designed for quick, targeted DNS queries without overwhelming you with options.
The Domain Name System (DNS) is the backbone of the internet, translating human-readable domain names (e.g., example.com) into machine-readable IP addresses (e.g., 93.184.216.34). To interact with DNS, system administrators, developers, and power users rely on command-line tools—and one of the most lightweight, flexible, and widely available tools is host.
In this blog, we’ll dive deep into host: what it is, how to use it, advanced features, best practices, troubleshooting, and how it compares to other DNS tools like nslookup and dig. By the end, you’ll be able to use host to solve real-world DNS problems with confidence.
OPTIONS: Modify behavior (e.g., -t for record type, -v for verbose).
HOSTNAME: The domain (e.g., example.com) or IP address (e.g., 8.8.8.8) to query.
DNS_SERVER: (Optional) The DNS server to use (e.g., 8.8.8.8 for Google DNS). If omitted, host uses your system’s default DNS (from /etc/resolv.conf or Network Settings).
Before diving into examples, let’s define common DNS records:
A Record: Maps a domain to an IPv4 address (e.g., example.com → 93.184.216.34).
AAAA Record: Maps a domain to an IPv6 address (e.g., example.com → 2606:2800:220:1:248:1893:25c8:1946).
MX Record: Specifies mail servers for a domain (e.g., example.com → mx1.example.com).
NS Record: Lists the authoritative name servers for a domain (e.g., example.com → ns1.example.com).
TXT Record: Stores text data (e.g., SPF, DKIM, or domain ownership verification).
CNAME Record: Creates an alias for a domain (e.g., www.example.com → example.com).
PTR Record: Maps an IP address to a domain (reverse lookup, e.g., 8.8.8.8 → dns.google).
HTTPS Record: A newer DNS record type (defined in RFC 9460) used for discovering alternative endpoints and service configuration for HTTPS connections.
By default, host uses your system’s DNS (e.g., your ISP’s server). To bypass this and use a custom DNS server (like Google’s 8.8.8.8 or Cloudflare’s 1.1.1.1), add the server as the last argument:
The -a option queries for all available records (equivalent to -t ANY). Note: Some DNS servers block ANY queries to prevent abuse, so this may not return all records.
host -a example.com
Output:
example.com has address 93.184.216.34
example.com has IPv6 address 2606:2800:220:1:248:1893:25c8:1946
example.com mail is handled by 0 mx.example.com.
example.com name server a.iana-servers.net.
example.com name server b.iana-servers.net.
The -C option queries the SOA (Start of Authority) records for a zone from all listed authoritative name servers and checks their consistency. This helps verify that all authoritative servers have synchronized zone data:
host -C example.com
Output:
Nameserver a.iana-servers.net:
SOA mname: dns.icann.org
SOA serial: 2025010101
SOA refresh: 7200
SOA retry: 3600
SOA expire: 1209600
SOA minimum: 3600
Why Use This?
Verify that all authoritative name servers for a zone have consistent records,
Detect stale or misconfigured secondary servers after zone updates,
The -6 option forces host to use IPv6 for query transport (the network connection to the DNS server). This is useful for testing IPv6 connectivity:
host -6 example.com
Output:
example.com has IPv6 address 2606:2800:220:1:248:1893:25c8:1946
Note: By default, host uses IPv4 for query transport. The -6 flag changes only the transport protocol used to reach the DNS server, not the type of records queried. Use -t AAAA if you specifically want to query for IPv6 address records.
DNS records can be cached (stored temporarily) by ISPs or local servers. To ensure accuracy, query 2–3 independent DNS servers (e.g., Google, Cloudflare, Quad9):
The host utility does not directly validate DNSSEC. For DNSSEC validation and troubleshooting, use delv (included in the BIND package) or online tools like DNSViz. To check if a domain has DNSSEC keys configured, query for DNSKEY records:
You’re maintaining legacy scripts that rely on nslookup.
nslookup was once planned for deprecation by ISC (the BIND developers), but that decision was reversed in 2004 with BIND 9.3. It remains fully supported, though host and dig are generally preferred for scripting and advanced use cases.
host is a swiss army knife for DNS lookups. It's simple enough for beginners to use for basic queries, yet powerful enough for experts to debug complex issues. Key takeaways:
Use -t to target specific record types,
Verify with multiple DNS servers,
Leverage -v for debugging,
Use -C to check SOA consistency across authoritative servers.
Whether you’re a system admin troubleshooting email delivery or a developer verifying a domain’s IP, host is an essential tool in your toolkit.