host

host

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.

Usage

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

Common Options

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

Examples

  1. Basic Query

    To query the A record for example.com:

    host example.com

    Output:

    example.com has address 93.184.216.34
  2. Query a Specific DNS Server

    To query the DNS server at 8.8.8.8 for the A record of example.com:

    host example.com 8.8.8.8
  3. 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.
  4. Verbose Output

    To query example.com with verbose output:

    host -v example.com
  5. 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.

Benefits of Using host

  1. Simple Interface: Easier to use for quick lookups compared to dig.

  2. Concise Output: Provides straightforward answers without the extensive details included in dig.

  3. Flexibility: Supports querying specific record types and DNS servers.

  4. Scripting: Can be used in scripts for simple DNS queries.

Use Cases

Example 1: Verify Mail Server Configuration

To check the mail exchange (MX) records for a domain:

host -t MX example.com

Example 2: Check Name Server Records

To list the authoritative name servers for a domain:

host -t NS example.com

Example 3: Reverse Lookup

To verify the hostname associated with an IP address:

host 93.184.216.34

Conclusion

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.

help

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

Last updated