Home·Terminal commands

host

Networking

Usage

host [-t <type>] <name> [server]

Answers a name lookup in two or three short lines of addresses and mail servers; it is the handiest for a quick check, but for the full record view you need dig.

Common flags

FlagMeaning
-t MXRestrict to one record type.
-aEverything, equivalent to -t ANY -v.
-vVerbose output closer to what dig prints.
-CFetch the SOA from every authoritative server, to spot one that is out of sync.
<ip>Give it an address and it does the reverse lookup by itself.

Examples

host example.com

Addresses and mail servers in three short lines.

host -t TXT example.com

Read the SPF or verification records.

host 8.8.8.8

Reverse lookup without needing -x.

When a connection fails, these narrow down how far it got — name not resolving, no route, or a blocked port.

How to read this

  • Square brackets [ ] mark a part you may leave out.
  • An ellipsis … means you can list more than one.
  • Flags are case-sensitive — in some commands -r and -R do different things.

Questions

Q. What does host do?

Answers a name lookup in two or three short lines of addresses and mail servers; it is the handiest for a quick check, but for the full record view you need dig.

Q. How do I type it?

host [-t <type>] <name> [server] — square brackets mark the parts you can leave out.

Q. How many flags are worth knowing?

5 are listed here; the full set is in man host. This command sits under Networking.

Related commands

man page: man host