How to Perform DNS Lookups Using the Linux host Command

When you type a website address like digitash.com into your browser, computers do not actually know how to connect to that word. They must first ask a Domain Name System (DNS) server to translate that human-readable domain name into a machine-readable IP address (like 192.168.1.50). If a website suddenly stops loading on your Linux server, the very first troubleshooting step is to verify whether your server’s DNS resolution is actually working. The simplest and cleanest tool for performing these manual DNS lookups directly from the Linux terminal is the host command.

Basic Forward DNS Lookups (Finding an IP Address)

The most common use case for the host command is asking a DNS server: “What is the IP address for this domain?”

  1. Open your Linux terminal.
  2. Type the command: host digitash.com
  3. Press Enter.

The output is incredibly clean and straightforward compared to complex tools like dig. It will simply return:
digitash.com has address 104.21.15.22
digitash.com has IPv6 address 2606:4700:3038::6815:f16

If it returns a not found: 3(NXDOMAIN) error, you immediately know that the domain either does not exist, or your server’s DNS resolver configuration (/etc/resolv.conf) is broken.

Finding Mail Servers (MX Records)

If you are troubleshooting email delivery issues and need to verify where a domain’s email is being routed, you can use the -t (type) flag to specify that you only want to see Mail Exchange (MX) records.

host -t mx google.com

This command will ignore standard web traffic IPs and instead output the specific servers responsible for receiving Gmail, such as smtp.google.com, along with their priority numbers.

Reverse DNS Lookups (Finding a Domain from an IP)

If you are analyzing a firewall access log and see a suspicious IP address repeatedly trying to connect to your server, you can use the host command in reverse. By feeding it an IP address, it will attempt to find the domain name associated with it.

host 8.8.8.8

The output will reveal the owner of that IP: 8.8.8.8.in-addr.arpa domain name pointer dns.google.

Querying a Specific DNS Server

By default, the host command asks your local ISP or your server’s default configured DNS resolver for the answer. However, DNS records take time to propagate globally. If you just updated a domain’s IP address and your local server still sees the old one, you can force the host command to bypass your local cache and ask a specific, public DNS server (like Cloudflare’s 1.1.1.1) directly.

To do this, simply append the IP address of the specific DNS server you want to query to the very end of the command:

host digitash.com 1.1.1.1

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.