Skip to content

host

Looks up names and addresses in DNS and prints the answer in a short, readable form.

host output

Syntax

host [OPTION]... NAME [SERVER]

Options

Option Description
-t TYPE Only this record type: A, AAAA, MX, TXT, NS, SOA
-a All records, in a detailed form like dig
-4, -6 Ask the DNS server over IPv4 or IPv6
SERVER Ask this DNS server instead of the configured one

Examples

Look up a name:

host example.com
example.com has address 198.51.100.7
example.com has IPv6 address 2001:db8:1::7
example.com mail is handled by 10 mail.example.com.

Without a type, host shows the IPv4 and IPv6 addresses and the mail server in one go.

Find the name of an IP address:

host 192.0.2.10
10.2.0.192.in-addr.arpa domain name pointer tuxdex-srv.example.com.

Show the TXT records, for example SPF:

host -t TXT example.com
example.com descriptive text "v=spf1 mx -all"

Ask a specific DNS server:

host example.com 198.51.100.53
Using domain server:
Name: 198.51.100.53
Address: 198.51.100.53#53
Aliases:

example.com has address 198.51.100.7
example.com has IPv6 address 2001:db8:1::7
example.com mail is handled by 10 mail.example.com.

A name that doesn't exist:

host nosuch.example.com
Host nosuch.example.com not found: 3(NXDOMAIN)

When do I need it?

  • For a quick check whether a name resolves and to which address
  • To check the reverse entry (PTR) of a mail server, which many receivers require
  • When dig gives you more detail than you need

PTR records for mail servers

Mail servers without a matching reverse entry are often rejected as spam. host with the server's IP address must return its host name, and that name must point back to the same address.

host ignores /etc/hosts too

Like dig, host only asks DNS. Use getent hosts NAME to see the result including /etc/hosts.

Distribution differences

Debian Ubuntu RHEL Arch
Package bind9-host bind9-host (installed) bind-utils bind

dig · resolvectl · getent