host — Simple DNS Lookup Utility
Practical guide to host — resolve hostnames to IP addresses, query DNS records by type, and run reverse lookups from the command line.
host is a lightweight DNS lookup tool from the BIND package: you resolve hostnames to IPv4 or IPv6 addresses in seconds, and reverse lookups work just as easily. Compared to dig, the output is shorter and immediately readable – ideal for quick checks on the command line. If you want to inspect A, MX, or TXT records without wading through lengthy response blocks, host is the tool to reach for.
Basic Lookups
host DOMAIN — Look up the A (IPv4), AAAA (IPv6), and MX records for a domain.
host example.comhost IP — Reverse DNS lookup — find the hostname for an IP address.
host 8.8.8.8host DOMAIN SERVER — Query a specific DNS server.
host example.com 8.8.8.8Record Type Queries
host -t TYPE DOMAIN — Query a specific record type.
host -t MX example.comhost -t A DOMAIN — Query IPv4 address records only.
host -t A example.comhost -t AAAA DOMAIN — Query IPv6 address records only.
host -t AAAA example.comhost -t MX DOMAIN — Query mail exchange records.
host -t MX example.comhost -t NS DOMAIN — Query nameserver records.
host -t NS example.comhost -t TXT DOMAIN — Query text records (SPF, DKIM, DMARC, verification).
host -t TXT example.comhost -t SOA DOMAIN — Query Start of Authority record.
host -t SOA example.comhost -t CNAME DOMAIN — Query canonical name (alias) records.
host -t CNAME www.example.comhost -t SRV _SERVICE._PROTO.DOMAIN — Query service records.
host -t SRV _sip._tcp.example.comhost -t CAA DOMAIN — Query Certificate Authority Authorization records.
host -t CAA example.comhost -a DOMAIN — Query all record types (equivalent to ANY). Verbose output.
host -a example.comOutput Options
host -v DOMAIN — Verbose output — show full DNS response including headers.
host -v example.comhost -4 DOMAIN — Use IPv4 transport only.
host -4 example.comhost -6 DOMAIN — Use IPv6 transport only.
host -6 example.comhost -W SECONDS DOMAIN — Set the query timeout in seconds.
host -W 10 example.comhost -R RETRIES DOMAIN — Set the number of retries on failure.
host -R 3 example.comhost -T DOMAIN — Use TCP instead of UDP for the query.
host -T example.comZone Transfer
host -l DOMAIN SERVER — List all records in a zone (AXFR zone transfer). Requires authorization.
host -l example.com ns1.example.comCommon Patterns
host DOMAIN | grep 'has address' — Extract only IPv4 addresses from the output.
host google.com | grep 'has address'host DOMAIN | grep 'mail' — Extract only mail server records.
host google.com | grep 'mail'host -t TXT _dmarc.DOMAIN — Check the DMARC policy for a domain.
host -t TXT _dmarc.example.comfor d in DOMAIN1 DOMAIN2 DOMAIN3; do echo "$d:"; host $d; echo; done — Look up multiple domains in a loop.
for d in google.com github.com example.com; do echo "$d:"; host $d; echo; donehost -t NS DOMAIN | awk '{print $4}' — Extract just the nameserver hostnames.
host -t NS example.com | awk '{print $4}' Conclusion
For a quick DNS check, host is the natural first choice: output is concise, the invocation is short, and reverse lookups work without extra flags. When you need DNSSEC details, specific response sections, or batch lookups from a file, switch to dig – the two tools complement each other perfectly.
Further Reading
- host(1) – manual page – every option at a glance
- BIND – Wikipedia – background on the DNS software suite that includes host
- Domain Name System – Wikipedia – DNS fundamentals