host
Lookup DNS records for a hostname
TLDR
Lookup A, AAAA, and MX records of a domain
Lookup a field (CNAME, TXT, ...) of a domain
Reverse lookup an IP
Specify an alternate DNS server to query
SYNOPSIS
host [options] name [server]
name can be a hostname or an IP address.
server is an optional DNS server to query instead of the default configured ones.
PARAMETERS
-a
all records. Equivalent to -t ANY.
-C
Compare SOA records on authoritative name servers.
-d
Enable debugging output.
-i
Display only the iP addresses in reverse lookups.
-l
List all hosts in a domain (zone transfer). Requires the name server to allow AXFR.
-N
Do not perform Non-authoritative lookups.
-r
Do not use recursion.
-s
simple output, terse.
-t type
Query for a specific record type (e.g., A, MX, NS, SOA, PTR, AAAA, ANY).
-T
Use TCP for queries instead of UDP.
-U
Use UDP for queries (default).
-v
Enable verbose output.
-V
Display the Version information and exit.
-w
wait indefinitely for a reply.
-W time
Wait for time seconds before timing out (default 5 seconds).
-4
Use IPv4 only.
-6
Use IPv6 only.
DESCRIPTION
The host command is a simple command-line utility used for performing DNS lookups. It translates hostnames to IP addresses (forward lookups) and IP addresses to hostnames (reverse lookups). It can query for various DNS record types, including A (address), AAAA (IPv6 address), MX (mail exchange), NS (name server), SOA (start of authority), and PTR (pointer). It's often preferred for quick, interactive lookups due to its clean and concise output format, making it easier to parse than tools like dig for simple queries.
CAVEATS
The output of host is generally less detailed than dig, which can be a limitation for complex DNS troubleshooting.
Performing zone transfers (-l option) may be blocked by DNS servers for security reasons.
For reverse lookups (IP to hostname), the reliability depends on proper PTR record configuration by the owner of the IP address block.
DEFAULT BEHAVIOR
When invoked without a specific query type (-t), host attempts to resolve the name to an A record (IPv4 address) or AAAA record (IPv6 address). If the input is an IP address, it performs a reverse PTR lookup by default.
SERVER SPECIFICATION
You can specify a particular DNS server to query by providing its IP address or hostname as the last argument, for example: host example.com 8.8.8.8. This is useful for testing specific DNS servers or for querying internal DNS zones.
HISTORY
The host command is part of the BIND (Berkeley Internet Name Domain) tools distribution, which is the most widely used DNS software on the internet. It was developed to provide a simpler alternative to nslookup and dig for common DNS query tasks, offering a more user-friendly output format for quick lookups. Its development has focused on reliability and ease of use for basic DNS diagnostics.