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.com

host IP — Reverse DNS lookup — find the hostname for an IP address.

host 8.8.8.8

host DOMAIN SERVER — Query a specific DNS server.

host example.com 8.8.8.8

Record Type Queries

host -t TYPE DOMAIN — Query a specific record type.

host -t MX example.com

host -t A DOMAIN — Query IPv4 address records only.

host -t A example.com

host -t AAAA DOMAIN — Query IPv6 address records only.

host -t AAAA example.com

host -t MX DOMAIN — Query mail exchange records.

host -t MX example.com

host -t NS DOMAIN — Query nameserver records.

host -t NS example.com

host -t TXT DOMAIN — Query text records (SPF, DKIM, DMARC, verification).

host -t TXT example.com

host -t SOA DOMAIN — Query Start of Authority record.

host -t SOA example.com

host -t CNAME DOMAIN — Query canonical name (alias) records.

host -t CNAME www.example.com

host -t SRV _SERVICE._PROTO.DOMAIN — Query service records.

host -t SRV _sip._tcp.example.com

host -t CAA DOMAIN — Query Certificate Authority Authorization records.

host -t CAA example.com

host -a DOMAIN — Query all record types (equivalent to ANY). Verbose output.

host -a example.com

Output Options

host -v DOMAIN — Verbose output — show full DNS response including headers.

host -v example.com

host -4 DOMAIN — Use IPv4 transport only.

host -4 example.com

host -6 DOMAIN — Use IPv6 transport only.

host -6 example.com

host -W SECONDS DOMAIN — Set the query timeout in seconds.

host -W 10 example.com

host -R RETRIES DOMAIN — Set the number of retries on failure.

host -R 3 example.com

host -T DOMAIN — Use TCP instead of UDP for the query.

host -T example.com

Zone Transfer

host -l DOMAIN SERVER — List all records in a zone (AXFR zone transfer). Requires authorization.

host -l example.com ns1.example.com

Common 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.com

for 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; done

host -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

  • dig – full-featured DNS queries with complete response output
  • nslookup – interactive DNS lookup, available on Windows and Linux
  • ping – check host reachability on the network