The host
command is a simple utility used for performing DNS lookups, similar to dig
, but with a more straightforward and user-friendly interface. It is part of the BIND (Berkeley Internet Name Domain) suite of tools.
host [options] name [server]
name
: The domain name to query.server
: The DNS server to query (optional). If not specified, the default DNS server configured in the system will be used.options
: Additional command-line options to control the behavior ofhost
.
-a
: Equivalent to-v -t ANY
, displays all available records.-t type
: Specifies the type of DNS record to query (e.g., A, MX, NS, etc.).-v
: Verbose output.-W time
: Sets the timeout for a query, in seconds.-R number
: Sets the number of retries for a query.
-
Basic Query
To query the A record for
example.com
:host example.com
Output:
example.com has address 93.184.216.34
-
Query a Specific DNS Server
To query the DNS server at
8.8.8.8
for the A record ofexample.com
:host example.com 8.8.8.8
-
Query for a Specific Record Type
To query the MX records for
example.com
:host -t MX example.com
Output:
example.com mail is handled by 10 mail.example.com.
-
Verbose Output
To query
example.com
with verbose output:host -v example.com
-
Reverse DNS Lookup
To perform a reverse DNS lookup for the IP address
192.0.2.1
:host 192.0.2.1
Output:
1.2.0.192.in-addr.arpa domain name pointer example.com.
- Simple Interface: Easier to use for quick lookups compared to
dig
. - Concise Output: Provides straightforward answers without the extensive details included in
dig
. - Flexibility: Supports querying specific record types and DNS servers.
- Scripting: Can be used in scripts for simple DNS queries.
To check the mail exchange (MX) records for a domain:
host -t MX example.com
To list the authoritative name servers for a domain:
host -t NS example.com
To verify the hostname associated with an IP address:
host 93.184.216.34
The host
command is a valuable tool for quick DNS lookups and basic troubleshooting. It complements dig
by providing a simpler, more user-friendly interface for querying DNS records. Whether you are verifying DNS configurations, checking mail servers, or performing reverse lookups, host
offers an efficient and straightforward way to get the information you need.
host: illegal option -- -
Usage: host [-aCdilrTvVw] [-c class] [-N ndots] [-t type] [-W time]
[-R number] [-m flag] [-p port] hostname [server]
-a is equivalent to -v -t ANY
-A is like -a but omits RRSIG, NSEC, NSEC3
-c specifies query class for non-IN data
-C compares SOA records on authoritative nameservers
-d is equivalent to -v
-l lists all hosts in a domain, using AXFR
-m set memory debugging flag (trace|record|usage)
-N changes the number of dots allowed before root lookup is done
-p specifies the port on the server to query
-r disables recursive processing
-R specifies number of retries for UDP packets
-s a SERVFAIL response should stop query
-t specifies the query type
-T enables TCP/IP mode
-U enables UDP mode
-v enables verbose output
-V print version number and exit
-w specifies to wait forever for a reply
-W specifies how long to wait for a reply
-4 use IPv4 query transport only
-6 use IPv6 query transport only