1. Library
  2. Computer Networks
  3. Tools and Commands
  4. Dns Tools

Updated 8 hours ago

The host command is opinionated. Where dig shows you everything and lets you decide what matters, host decides for you—and it's usually right.

Want to know where a domain points? Host gives you the IP address, the IPv6 address if one exists, and the mail server. Three lines. Done. No TTL values you didn't ask for, no authority sections, no additional records. Just answers.

The Basic Query

host example.com

Output:

example.com has address 93.184.216.34
example.com has IPv6 address 2606:2800:220:1:248:1893:25c8:1946
example.com mail is handled by 0 .

That's it. Host looked up multiple record types and presented them in plain English. No flags required.

Reverse Lookups Just Work

Give host an IP address, and it automatically performs a reverse lookup:

host 93.184.216.34

Output:

34.216.184.93.in-addr.arpa domain name pointer example.com.

No -x flag. No special syntax. Host recognizes an IP when it sees one and does the right thing.

When You Want Specific Records

The -t flag lets you ask for exactly one record type:

host -t MX example.com

Output:

example.com mail is handled by 10 mail1.example.com.
example.com mail is handled by 20 mail2.example.com.

The common record types:

host -t A example.com      # IPv4 addresses
host -t AAAA example.com   # IPv6 addresses
host -t MX example.com     # Mail servers
host -t NS example.com     # Nameservers
host -t TXT example.com    # Text records (SPF, DKIM, etc.)
host -t CNAME www.example.com  # Aliases
host -t SOA example.com    # Start of Authority

Asking a Specific DNS Server

Put the server after the domain:

host example.com 8.8.8.8

Output:

Using domain server:
Name: 8.8.8.8
Address: 8.8.8.8#53
Aliases:

example.com has address 93.184.216.34

Host tells you which server answered. Useful when you're checking whether DNS changes have propagated to different resolvers.

When You Need More Detail

The -v flag switches host into verbose mode, revealing the full DNS protocol exchange:

host -v example.com

Output:

Trying "example.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12345
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;example.com.                   IN      A

;; ANSWER SECTION:
example.com.            86400   IN      A       93.184.216.34

Received 56 bytes from 192.168.1.1#53 in 12 ms

Now you see TTL values, response timing, and the full query structure. When you need dig-level detail but prefer host's interface, -v delivers.

Reading the Output

Host's responses are sentences, not data dumps:

Success:

example.com has address 93.184.216.34

Multiple addresses (load balancing):

example.com has address 93.184.216.34
example.com has address 93.184.216.35

Alias chain:

www.example.com is an alias for example.com.
example.com has address 93.184.216.34

Domain doesn't exist:

Host example.com not found: 3(NXDOMAIN)

Server error:

Host example.com not found: 2(SERVFAIL)

Record type doesn't exist:

example.com has no MX record

The error messages tell you exactly what happened. NXDOMAIN means the domain doesn't exist. SERVFAIL means the DNS server choked. "has no MX record" means the domain exists but doesn't accept email. Host respects your time even when things go wrong.

Scripting

Host's predictable output makes it excellent for scripts:

Extract an IP address:

IP=$(host example.com | grep "has address" | head -1 | awk '{print $4}')

Check if a domain exists:

if host example.com > /dev/null 2>&1; then
    echo "Domain exists"
else
    echo "Domain not found"
fi

Get mail servers:

host -t MX example.com | awk '{print $7}'

Compare DNS servers:

echo "Google: $(host example.com 8.8.8.8 | grep 'has address' | awk '{print $4}')"
echo "Cloudflare: $(host example.com 1.1.1.1 | grep 'has address' | awk '{print $4}')"

Useful Options

host -a example.com      # All records (verbose + ANY)
host -R 3 example.com    # Retry 3 times on failure
host -W 5 example.com    # 5 second timeout
host -T example.com      # Force TCP instead of UDP
host -4 example.com      # IPv4 transport only
host -6 example.com      # IPv6 transport only

What Host Won't Do

Host trades power for simplicity:

  • No tracing: Can't follow the delegation path from root servers like dig +trace
  • No DNSSEC validation: Limited support for checking signatures
  • No interactive mode: One query per invocation
  • No output formatting options: You get what you get

When you need these features, use dig. Host isn't trying to be dig. It's trying to be fast and right.

The Philosophy

Every tool makes tradeoffs. Dig chose completeness—show everything, let the user filter. Nslookup chose interactivity—let users explore DNS conversationally. Host chose opinion—show what matters most, in the clearest possible way.

For quick lookups, for scripts, for the ten times a day you just need to know where something points: host gets out of your way and gives you the answer.

Frequently Asked Questions About the host Command

Was this page helpful?

😔
🤨
😃