The host Command Explained

Modern operating systems offer a variety of tools to retrieve DNS records. One of the simplest and most efficient tools for this purpose is the host command, a lightweight utility designed for quick, human-readable DNS queries on Linux and Unix-like systems.

In this guide, we’ll explain how it works, break down its syntax and options, and walk you through some practical examples. Whether you’re troubleshooting DNS issues or performing quick lookups, you’ll learn how to use host effectively — as well as what its limitations are and when you might want to consider alternatives like nslookup, dig, or a DNS Lookup API.

TL;DR: What You Need to Know About the host Command

The host command is a command-line tool used to perform forward and reverse DNS lookups (that is, getting the IP address to which domain names resolve and vice versa). It’s primarily designed for Linux and Unix-like operating systems.

Since the host command is designed for quick lookups, it has some limitations, which we detail in the table below.

LimitationsWorkaround
Does not show Time to Live (TTL) by defaultUse the -v (verbose) flag or a specialized DNS lookup API
Outputs full sentences in English, which are hard for scripts to parse.Use the dig command or DNS Lookup API for structured output
Restricted to Linux and Unix-like systemsUse the nslookup or dig commands on Windows or the DNS Lookup API for an OS-agnostic option.

Installing the host Command

The host command is part of the DNS utilities package (typically provided by BIND). It is already installed on most systems (excluding Windows).

On Linux and macOS

To check if you have the host command, open the Terminal and type:

which host

This would give you the path where host is installed in your environment. If for some reason host is not installed, you can get it (together with the rest of bind-utils) using a package manager that your system supports — whether it’s apt, dnf, yum, or homebrew (on macOS). 

The commands to install host would look like this:

sudo apt install dnsutils (Debian/Ubuntu/Kali)

sudo dnf install bind-utils (Red Hat/CentOS)

brew install bind (macOS)

On Windows

The host command is not part of Windows. However, you can get it using the Windows Subsystem for Linux (we’ll get to this later in the article).

How the host Command Works

When you run a query, the host command utility sends a request to a DNS resolver specified in the config or in the command itself. That resolver doesn’t always answer the query itself — instead, it may contact other DNS servers (starting from root servers down to the domain’s authoritative servers) until it finds the result. The host command then displays a simplified, human-readable version of that final answer, without showing the intermediate steps or low-level protocol details.

The host Command Syntax and Parameters

The basic structure of a host command is straightforward — all you really need is the base command (host) and the IP address or domain, such as:

host google.com

or

host 8.8.8.8

However, you might want to add an option or a specific DNS server, depending on what you want to see. In that case, the syntax would be:

host [options] [address] [server]

Here’s an example host command:

host -v google.com ns3.google.com

The table below details each component of the host command syntax.

ComponentDescriptionRequired?
hostThe base command utility.Yes
[options]Flags that modify the query (listed in the next table).No
[address]The domain name (e.g., google.com) or IP address (e.g., 8.8.8.8) you want to look up.Yes
[server]The specific DNS server you want to query (e.g., ns3.google.com). If omitted, it uses your local system defaults.No

The host Command Options

These are the flags you can use to customize the information you receive.

OptionFunctionSample Command
-aAttempts to display all available DNS records with verbose output (may need to include a public DNS server; output may be incomplete due to server restrictions)host -a google.com 8.8.8.8
-ASimilar to -a but omits security records (not universally supported — for example, it is not included in the implementation of host on macOS)host -A example.com 8.8.8.8
-c classQueries a specific DNS class (e.g., IN, CH, HS — Internet, Chaos, and Hesiod)host -c IN -t A google.com
-CQueries all authoritative nameservers for their SOA records to help identify inconsistencieshost -C apple.com
-dEnables debugging mode host -d google.com
-m flagSets memory debugging flags (trace, record, or usage)host -m trace google.com
-N dotsSets the number of dots required before a root lookup is attemptedhost -N 2 [your.internal.host]
-rDisables recursive processing for the queryhost -r google.com 8.8.4.4
-R numberSets the number of retries for UDP packetshost -R 5 example.com
-sStops the query if a SERVFAIL response is receivedhost -s [failing-domain.com]
-t typeSpecifies the query type (MX, NS, TXT, ANY, etc.)host -t MX microsoft.com
-TForces the use of TCP for the DNS queryhost -T github.com
-UForces the use of UDP for the DNS query, preventing fallback to TCPhost -U google.com
-vEnables debug/verbose output (equivalent to -d)host -v example.com
-VPrints the version number of the host utilityhost -V
-wTells the command to wait forever for a replyhost -w archive.org
-W timeSets the timeout in seconds to wait for a replyhost -W 3 google.com
-4Uses IPv4 query transport onlyhost -4 example.com
-6Uses IPv6 query transport onlyhost -6 example.com

What Does the host Command Do? (with Examples)

Now that you know the syntax, let’s try some examples to show how to run common host command queries.

1. Identify a Domain’s IP Address

To do a basic DNS lookup and see the content of a domain’s A or AAAA records, simply type the domain name after the command.

Syntax: host [domain name]

Example: host google.com

host command for domain to IP mapping (A and AAAA records)

If you want to see more details about the query, you can use the -v option.

host -v google.com
host command with a verbose flag

2. Perform a Reverse DNS Lookup

You can use the host command to do a reverse lookup, which helps you find the hostname associated with a specific IP address.

Syntax: host [IP address]

Example: host 157.240.3.20

host command for ip to domain mapping

3. Retrieve Specific DNS Records

You can look up specific types of DNS records to view domain details using the -t flag. Below are some examples:

Mail Exchange Information (MX Record)

Syntax: host -t MX [domain name]

Example: host -t MX google.com

host command to retrieve MX records

SOA Record

Syntax: host -t SOA [domain name]

Example: host -t SOA example.com

host command checking SOA records

TXT Record

Syntax: host -t TXT [domain name]

Example: host -t TXT example.com

host command retrieving TXT records

Nameservers within NS Records

Syntax: host -t NS [domain name]

Example: host -t NS example.com

host command retrieving NS records

4. Compare Start of Authority (SOA) Records

To verify that all nameservers have the same SOA record, you can use the -C flag. This is a diagnostic tool that sends a query to all authoritative nameservers for a domain to help ensure DNS consistency.

Syntax: host -C [domain name]

Example: host -C example.com

host command retrieving SOA records

5. View Full DNS Details

The -a flag triggers the ANY query, which attempts to retrieve all available DNS records for a domain. However, many ISP DNS servers have been configured to disable the ANY query for security purposes, as it can be used in distributed denial-of-service (DDoS) attacks

As a workaround, you can still use the -a flag, but try querying a public server (e.g., Google’s 8.8.8.8).

Syntax: host -a [domain name] [server]

Example: host -a example.com 8.8.8.8

host command attempting to retrieve ANY records

Is there a Windows Equivalent to host?

The host command is not natively available in the Windows Command Prompt or PowerShell. So, for similar DNS tasks, Windows users use the nslookup command.

However, you can use the host command on Windows by installing the Windows Subsystem for Linux (WSL) to run a full Linux distribution, such as Ubuntu, directly on your Windows machine.

Comparing DNS Commands: host vs. nslookup vs. dig

You may have noticed that there are three different commands to work with DNS queries. It’s not accidental, and even though they overlap significantly, they are different and have different purposes.

Here’s a quick look at the three command utilities before we detail their differences:

Featurehostdignslookup
Primary OSLinux / macOSLinux / macOSLinux / macOS / Windows 
Output StyleHuman-readable sentencesRaw DNS response formatSemi-structured, human-readable output
Best for Quick DNS lookupsDeep troubleshooting and scriptingInteractive queries and basic DNS troubleshooting (especially on Windows)
ParsingSomewhat easyScript-friendlyHard (inconsistent output)

For Windows environments, the nslookup command is one of the most commonly used tools for DNS queries. It works natively on Windows without needing a Linux subsystem. It has an interactive mode that lets you perform multiple queries without retyping the command.

nslookup is available on almost every operating system, including older versions of Unix and Windows.

host is the easiest to work with of all three DNS commands. It gives consistent, human-readable yet parsable results. However, it has some limitations when it comes to depth — no tracing, limited DNSSEC support, etc.

dig is a more functional yet more verbose command that is meant for deep debugging or scripting. It can do all that host does and more, but is not as human-friendly when it comes to output.

For automation at scale, developers often prefer to use an API like DNS Lookup API instead of command-line tools. No matter which command you choose — host, dig, or nslookup — you can eventually run into resolver rate limiting if you try to perform too many queries. Specialized APIs allow you to avoid such issues while providing consistent, standardized output.

Below is an example of using the DNS Lookup API to get all DNS records of example[.]com with the help of the curl command: 

curl "https://www.whoisxmlapi.com/whoisserver/DNSService?apiKey=YOUR_API_KEY&domainName=example.com&type=_all" > example.xml

The output of this command would be saved in the example.xml file that looks like this:

<?xml version="1.0" encoding="utf-8"?><DNSData>
 <domainName>example.com</domainName>
 <types>
   <int>-1</int>
 </types>
 <dnsTypes>_all</dnsTypes>
 <audit>
   <createdDate>2026-04-10 15:23:07 UTC</createdDate>
   <updatedDate>2026-04-10 15:23:07 UTC</updatedDate>
 </audit>
 <dnsRecords>
   <TXTRecord>
     <type>16</type>
     <dnsType>TXT</dnsType>
     <name>example.com.</name>
     <ttl>300</ttl>
     <rRsetType>16</rRsetType>
     <rawText>example.com.   300 IN  TXT "v=spf1 -all"</rawText>
     <strings>
       <string>v=spf1 -all</string>
     </strings>
   </TXTRecord>
   <TXTRecord>
     <type>16</type>
     <dnsType>TXT</dnsType>
     <name>example.com.</name>
     <ttl>300</ttl>
     <rRsetType>16</rRsetType>
     <rawText>example.com.   300 IN  TXT "_k2n1y4vw3qtb4skdx9e7dxt97qrmmq9"</rawText>
     <strings>
       <string>_k2n1y4vw3qtb4skdx9e7dxt97qrmmq9</string>
     </strings>
   </TXTRecord>
   <ARecord>
     <type>1</type>
     <dnsType>A</dnsType>
     <name>example.com.</name>
     <ttl>120</ttl>
     <rRsetType>1</rRsetType>
     <rawText>example.com.   120 IN  A 104.20.23.154</rawText>
     <address>104.20.23.154</address>
   </ARecord>
   <ARecord>
     <type>1</type>
     <dnsType>A</dnsType>
     <name>example.com.</name>
     <ttl>120</ttl>
     <rRsetType>1</rRsetType>
     <rawText>example.com.   120 IN  A 172.66.147.243</rawText>
     <address>172.66.147.243</address>
   </ARecord>
   <NSRecord>
     <type>2</type>
     <dnsType>NS</dnsType>
     <name>example.com.</name>
     <additionalName>elliott.ns.cloudflare.com.</additionalName>
     <ttl>77208</ttl>
     <rRsetType>2</rRsetType>
     <rawText>example.com.   77208 IN  NS  elliott.ns.cloudflare.com.</rawText>
     <target>elliott.ns.cloudflare.com.</target>
   </NSRecord>
   <NSRecord>
     <type>2</type>
     <dnsType>NS</dnsType>
     <name>example.com.</name>
     <additionalName>hera.ns.cloudflare.com.</additionalName>
     <ttl>77208</ttl>
     <rRsetType>2</rRsetType>
     <rawText>example.com.   77208 IN  NS  hera.ns.cloudflare.com.</rawText>
     <target>hera.ns.cloudflare.com.</target>
   </NSRecord>
   <SOARecord>
     <type>6</type>
     <dnsType>SOA</dnsType>
     <name>example.com.</name>
     <ttl>318</ttl>
     <rRsetType>6</rRsetType>
     <rawText>example.com.   318 IN  SOA elliott.ns.cloudflare.com. dns.cloudflare.com. 2401294294 10000 2400 604800 1800</rawText>
     <admin>dns.cloudflare.com.</admin>
     <host>elliott.ns.cloudflare.com.</host>
     <expire>604800</expire>
     <minimum>1800</minimum>
     <refresh>10000</refresh>
     <retry>2400</retry>
     <serial>2401294294</serial>
   </SOARecord>
   <AAAARecord>
     <type>28</type>
     <dnsType>AAAA</dnsType>
     <name>example.com.</name>
     <ttl>118</ttl>
     <rRsetType>28</rRsetType>
     <rawText>example.com.   118 IN  AAAA  2606:4700:10:0:0:0:ac42:93f3</rawText>
     <address>2606:4700:10:0:0:0:ac42:93f3</address>
   </AAAARecord>
   <AAAARecord>
     <type>28</type>
     <dnsType>AAAA</dnsType>
     <name>example.com.</name>
     <ttl>118</ttl>
     <rRsetType>28</rRsetType>
     <rawText>example.com.   118 IN  AAAA  2606:4700:10:0:0:0:6814:179a</rawText>
     <address>2606:4700:10:0:0:0:6814:179a</address>
   </AAAARecord>
   <MXRecord>
     <type>15</type>
     <dnsType>MX</dnsType>
     <name>example.com.</name>
     <additionalName>.</additionalName>
     <ttl>261</ttl>
     <rRsetType>15</rRsetType>
     <rawText>example.com.   261 IN  MX  0 .</rawText>
     <priority>0</priority>
     <target>.</target>
   </MXRecord>
 </dnsRecords>
</DNSData>

Using Windows Subsystem for Linux (WSL)

If you prefer the simplicity of host, you can access it on Windows by setting up WSL. This gives you a native Linux environment without the overhead of a virtual machine. Follow these steps to set up WSL:

1. Install WSL

Open PowerShell as an Administrator and run:

wsl --install
installing WSL

This command enables the required features and installs Ubuntu Linux by default. You will need to restart your computer to finish the setup.

2. Set Up Your Linux Distribution

After restarting, open the Ubuntu app from your Start menu. Follow the prompts to create a username and password.

Ubuntu running under WSL

3. Install DNS Utilities

The host command is part of the bind9-host or dnsutils package. Update your package list and install the tools with these commands:

sudo apt update
command to update apt

sudo apt install bind9-host (to only get the host command) or sudo apt install dnsutils (to install the dig, host, and nslookup bundle)

command to install dnsutils

Note: On some Linux distributions, dnsutils has been renamed or transitioned to a package called bind9-dnsutils. If you try to install dnsutils and your system says it cannot be found, try this command instead:

sudo apt install bind9-dnsutils

4. Run the host Command

You can now start using the host command directly inside the WSL terminal.

host command on Windows

Conclusion

The host command is a simple tool for DNS troubleshooting. While it has some limitations in scripting and depth, many use it for quick and readable manual lookups. 

But for more advanced needs or automated systems, tools like dig or a dedicated DNS Lookup API are better alternatives.

Frequently Asked Questions about host Command

What is the host command used for?

The host command is a DNS lookup utility that lets you look up DNS records. It can find the IP address of a given domain name (forward DNS lookup). It can also be used to find domains associated with an IP address (reverse DNS lookup).

There are also optional flags that allow you to retrieve the DNS configurations for a given domain, including CNAME records, TXT records, A records, and PTR records.

How to get host in cmd?

You need the Windows Subsystem for Linux (WSL) to run the host command in a Windows environment. We described how to set this up in the section “Using Windows Subsystem for Linux (WSL).”

Try our WhoisXML API for free

Get Started

Have questions?

We are here to listen. For a quick response, please select your request type. By submitting a request, you agree to our Terms of Service and Privacy Policy.