Linux host Command: Look Up DNS Names and Addresses

host is a simple DNS tool that looks up domain names to IP addresses and IP addresses to reverse names. It is convenient for quick checks and allows you to specify the record type for queries.

What is the host command?

By default, it uses the DNS server set on the system, but you can specify a different server as the last argument. If you enter an IP address, it attempts a PTR-based reverse lookup. Compared to dig, the output is concise, but full DNS information may be needed for analyzing complex responses.

Basic syntax

host [options] name|IP [DNS server]

Installed implementations and options may vary depending on the distribution. Check the current system description with man host.

Examples

Domain address lookup

Quickly check basic results such as A and AAAA.

host example.com

Mail record lookup

Check mail receiving servers using MX records.

host -t MX example.com

Reverse Lookup

Check if there is a PTR name registered for the IP.

host 192.0.2.1

Simple DNS Lookup Results

host is a simple DNS lookup tool to find the address from a name or to check the reverse name of an address.

host example.com

Example of output format (actual addresses may vary):

example.com has address 192.0.2.10

There may be multiple IPv4 and IPv6 addresses for the same name, so the output can have multiple lines. host -t MX domain looks up mail exchange records. If there are connection issues, check separately whether the DNS results are returned and whether the target port is actually open.

Main Options and Format

Options/Format Description
-t format Specify the DNS record type to query.
-a Query with detailed information.
-v Display detailed contents of the query and response.
-4 / -6 Limit the IP version used for sending the query.
Last server argument Query the specified DNS server instead of the default server.

Precautions when using

The fact that there are no reverse lookup results means that there is no PTR record or it cannot be accessed, not that the IP is unused. DNS responses and actual connectivity are separate matters. If the record is not visible, check the queried server, cache, and record format.

Frequently Asked Questions

Are host and hostname the same command?

No. host queries DNS information, while hostname displays or sets the current system's host name.

Official Documentation

The exact behavior of options and implementation differences can be found in the official documentation related to host.

More in This Category
Linux mktemp Command: Create Secure Temporary Files and Directories

Linux mktemp Command: Create Secure Temporary Files and Directories

Learn how to create unpredictable temporary files and directories with Linux mktemp, use templates and TMPDIR, clean up with trap, and avoid unsafe dry runs.

Linux apk Command: Manage Packages on Alpine Linux

Linux apk Command: Manage Packages on Alpine Linux

Learn how to manage Packages on Alpine Linux with the Linux apk command, including practical examples, key options, and important precautions.

Linux wget Command: Download Files from URLs

Linux wget Command: Download Files from URLs

Learn how to download Files from URLs with the Linux wget command, including practical examples, key options, and important precautions.

Linux mount Command: Inspect and Mount Filesystems

Linux mount Command: Inspect and Mount Filesystems

Learn how to inspect and Mount Filesystems with the Linux mount command, including practical examples, key options, and important precautions.

Linux shutdown Command: Schedule a Shutdown or Restart

Linux shutdown Command: Schedule a Shutdown or Restart

Learn how to schedule a Shutdown or Restart with the Linux shutdown command, including practical examples, key options, and important precautions.

Linux alias Command: Create Command Shortcuts

Linux alias Command: Create Command Shortcuts

Learn how to use the Linux alias command to create, inspect, and make shell command aliases persistent, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux sync Command: Flush Buffered Writes to Storage

Linux sync Command: Flush Buffered Writes to Storage

Learn how to flush Buffered Writes to Storage with the Linux sync command, including practical examples, key options, and important precautions.

Linux chown Command: Change File Owner and Group

Linux chown Command: Change File Owner and Group

Learn how to change File Owner and Group with the Linux chown command, including practical examples, key options, and important precautions.

Linux Tutorial / Linux Terminal and Shell Basics: Command Syntax and Finding Help

Linux Tutorial / Linux Terminal and Shell Basics: Command Syntax and Finding Help

Learn the difference between a terminal and a shell, read command syntax and output, and use Bash help tools through a short hands-on exercise.

Linux date Command: Display and Format the Current Time

Linux date Command: Display and Format the Current Time

Learn how to display and Format the Current Time with the Linux date command, including practical examples, key options, and important precautions.