The host Command

Run a Speed Test

host is a simple DNS lookup utility that returns clean, readable output — the fastest way to resolve a hostname, check mail servers, or verify a DNS record from the command line.

What the host Command Does

The host command sends DNS queries and returns results in plain English. Unlike dig, which prints full protocol-level detail, host strips the output down to just the facts: the IP address a hostname resolves to, the mail servers for a domain, or the hostname behind an IP. This makes it ideal for quick interactive checks and easy to parse in shell scripts where you only need the answer, not the metadata.

host is part of the BIND utilities package and is available on Linux and macOS by default. It is not available on Windows — Windows users should use nslookup instead.

Basic Usage

The simplest form resolves a hostname to its IP addresses:

host google.com

Output:

google.com has address 142.250.80.46
google.com has IPv6 address 2607:f8b0:4004:c1b::65
google.com mail is handled by 10 smtp.google.com.

Notice that host returns A records, AAAA records, and MX records in a single query by default. The plain-language labels — "has address," "has IPv6 address," "mail is handled by" — make the output self-explanatory.

Querying Specific Record Types

Use the -t flag to request a specific record type:

host -t MX gmail.com
host -t TXT google.com
host -t NS google.com
host -t SOA google.com
host -t AAAA google.com

This is equivalent to nslookup -type=MX or dig -t MX, but the output from host is considerably more concise.

Querying All Record Types at Once

The -a flag ("all") queries for all record types and returns verbose output similar to dig:

host -a google.com

This is a quick way to audit every DNS record configured for a domain without running multiple separate queries.

Reverse DNS Lookup

Pass an IP address and host performs a PTR (pointer) lookup automatically:

host 8.8.8.8

Output:

8.8.8.8.in-addr.arpa domain name pointer dns.google.

Reverse DNS is useful for verifying that a server's IP resolves back to a meaningful hostname, which is important for mail server reputation and network auditing.

Querying a Specific Resolver

Add a resolver IP as the final argument to bypass your system's default DNS server:

host google.com 1.1.1.1
host google.com 8.8.8.8

This is useful when you want to check whether a DNS change has propagated to a specific public resolver, or when you suspect your local resolver is returning stale cached data.

Verbose Mode

The -v flag enables verbose output, which includes TTL values, record classes, and the server that answered the query — bringing the output closer to what dig produces while retaining the host format:

host -v google.com

host vs dig vs nslookup

Feature host dig nslookup
Available on Windows No No (unless installed) Yes (built-in)
Available on Linux/macOS Yes Yes Yes
Output verbosity Minimal Full protocol detail Moderate
Good for scripting Yes (clean output) Yes (with +short) Limited
Shows TTL by default No Yes No
Interactive mode No No Yes
Reverse lookup Auto-detected Requires -x flag Auto-detected

When to Use host

Use host when you want a fast, readable answer and don't need TTL values or full protocol information. It is particularly well-suited for shell scripting because its output format is consistent and easy to process with standard tools like grep and awk. For example, extracting just the IP address of a domain takes a single pipeline:

host google.com | grep "has address" | awk '{print $4}'

For deep DNS debugging — checking DNSSEC flags, inspecting authority sections, or measuring query timing — dig is the better choice. For Windows environments where neither host nor dig is available by default, nslookup covers the same ground.

Frequently Asked Questions

Is host available on Windows?

No. The host command is not available on Windows. Windows users should use nslookup, which is built in, or install dig via BIND utilities. On Linux and macOS, host is typically available by default as part of the bind-utils or dnsutils package.

How do I look up all DNS records for a domain with host?

Use the -a flag: host -a example.com. This queries for all record types and returns the full DNS answer in a verbose format similar to dig. It is the quickest way to see every record configured for a domain in a single command.

How is host different from dig?

host produces much simpler, human-readable output — one line per record — while dig returns the full DNS response with QUESTION, ANSWER, AUTHORITY, and ADDITIONAL sections including TTL values and flags. dig is better for scripting and deep analysis; host is better for quick interactive checks.

How do I do a reverse DNS lookup with host?

Pass the IP address as the argument: host 8.8.8.8. host automatically detects that you passed an IP and performs a PTR lookup, returning the hostname associated with that address. This is equivalent to nslookup 8.8.8.8 or dig -x 8.8.8.8.

Can I specify which DNS server host should use?

Yes. Add the resolver IP as the last argument: host example.com 1.1.1.1. This bypasses your system's configured DNS and sends the query directly to 1.1.1.1. This is useful for comparing responses between different resolvers or testing DNS changes before they propagate.

What does "has address" mean in host output?

"has address" indicates an A record — an IPv4 address mapping. "has IPv6 address" indicates an AAAA record. "mail is handled by" indicates an MX record. "descriptive text" indicates a TXT record. These plain-language labels make host output easy to parse at a glance without needing to know DNS record type codes.

Related Guides

More From This Section