host Command: Tutorial & Examples

Querying DNS Servers

The host command in Linux is a simple and straightforward tool used for DNS (Domain Name System) lookup operations. It's primarily used to convert human-friendly domain names into machine-friendly IP addresses, but it can also be used to retrieve a variety of other DNS records.

Understanding the host Command

The DNS is an essential part of internet communication. It translates human-readable domain names, such as "", into IP addresses that machines can understand. The host command is a simple utility in the shell that performs DNS lookups. It's a versatile command that can retrieve various types of DNS records, including A (address), CNAME (canonical name), MX (mail exchange), and NS (name server) records.

Why is the host Command Important?

Understanding and using the host command is vital for system administrators and anyone dealing with network-related tasks. Its ability to translate domain names to IP addresses and vice versa is crucial in diagnosing and troubleshooting network failures. Additionally, it's valuable in gathering information about a domain, such as finding out the mail servers or name servers it uses.

Using the host Command

Using the host command is straightforward. Here are some typical uses:

  1. To get the IP address of a domain:


    The typical output should look like: has address
  2. To get the domain name associated with an IP address:


    The typical output should look like: domain name pointer
  3. To get the MX (Mail Exchange) records of a domain:

    host -t mx

    The typical output should look like: mail is handled by 10

Common Issues and Their Solutions

While the host command is generally reliable, you might encounter a few issues. For instance, if you get an output like "Host not found: 3(NXDOMAIN)", it means that the domain does not exist or is not reachable. This could be due to a network failure or incorrect DNS settings at the domain provider.

If you're trying to find the domain name associated with an IP address and get no result, it might be because the IP doesn't have a PTR record. In this case, you would need to contact the IP address owner or ISP to create a PTR record.


The host command is a valuable tool for anyone dealing with networking or server administration. By understanding and utilizing this command, you can diagnose network issues, gather information about domains, and more. Remember, the host command is just one of many tools available in your shell toolbox.

Except where otherwise noted, content on this site is licensed under a CC BY-SA 4.0 license CC BY SA