Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk17 min

Linux and Unix host Command Examples

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The host command is a simple DNS lookup utility available on many Linux and Unix systems. It is commonly used to resolve domain names to IP addresses, perform reverse lookups from IP addresses to hostnames, and inspect DNS records such as MX, NS, TXT, CNAME, and SOA entries.

Because its output is concise and readable, host is useful for quick checks as well as everyday DNS troubleshooting. You can use it to confirm whether a name resolves correctly, query a specific DNS server, compare results between resolvers, and identify issues such as missing records, incorrect mail routing, or reverse DNS mismatches.

As an Amazon Associate I earn from qualifying purchases.

What the host Command Does

The host command is a DNS lookup utility available on most Linux and Unix-like systems. It asks DNS servers for information about domain names, hostnames, and IP addresses, then prints the answer in a compact, readable format. In everyday use, it is often used to check whether a name resolves, which IP address a domain points to, which mail servers handle a domain, or whether an IP address has a reverse DNS name.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

At its simplest, host converts a hostname into one or more IP addresses. For example:

host example.com

Typical output may look like this:

example.com has address 93.184.216.34

This means DNS returned an A record for example.com, mapping the name to the IPv4 address 93.184.216.34. If the domain also has IPv6 records, you may see an additional line such as:

example.com has IPv6 address 2606:2800:220:1:248:1893:25c8:1946

In that case, host has found an AAAA record, which maps the name to an IPv6 address. Mulle lines are normal when a domain uses more than one address for redundancy, load balancing, or dual-stack IPv4 and IPv6 connectivity.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The command can also perform reverse lookups. Instead of asking “which address belongs to this name?”, it asks “which name belongs to this address?” For example:

host 8.8.8.8

A typical response is:

8.8.8.8.in-addr.arpa domain name pointer dns.google.

This indicates that the IP address has a PTR record pointing to dns.google.. Reverse DNS is commonly checked when diagnosing mail delivery problems, server identity issues, logging output, or access control rules that depend on hostnames.

Although host can query many DNS record types, it is intentionally simpler than tools such as dig. Its output is designed for quick inspection rather than full DNS packet analysis. For example, you can ask for mail exchanger records with:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

host -t MX example.com

The output may include lines like:

example.com mail is handled by 10 mail.example.com.

The number before the mail server is the MX preference value. Lower values are preferred first, so a mail server with priority 10 is tried before one with priority 20.

The host command uses the system’s configured resolver by default. On Linux, this usually means it follows settings from files such as /etc/resolv.conf or from a local resolver managed by services like systemd-resolved, NetworkManager, or a caching DNS daemon. You can also direct a query to a specific DNS server, which is useful when comparing public DNS results with internal corporate DNS or checking whether a recent DNS change has propagated.

Common results include successful answers, aliases, and failures. If a name is an alias, host may show a CNAME record before the final address. If the domain does not exist, you may see a message such as Host nonexistent.example not found: 3(NXDOMAIN). If the DNS server cannot be reached, times out, or refuses the query, the message will point to a resolver or network problem rather than a missing record.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In short, host is a fast command-line tool for confirming DNS behavior from the machine where you run it. It helps answer practical questions such as whether a hostname resolves, whether IPv6 is configured, which mail servers are published, what reverse DNS says, and whether different DNS servers return different answers.

Basic Forward and Reverse DNS Lookups

The most common use of the host command is a forward DNS lookup: resolving a domain name to one or more IP addresses. This checks the address records published for a hostname and is often the first step when verifying whether DNS is working for a website, mail server, API endpoint, or internal service.

To look up the IP address for a hostname, pass the name directly to host:

host example.com

Typical output looks like this:

example.com has address 93.184.216.34
example.com has IPv6 address 2606:2800:220:1:248:1893:25c8:1946

The line containing has address shows an IPv4 address from an A record. The line containing has IPv6 address shows an IPv6 address from an AAAA record. A domain may return one address, several addresses, only IPv4, only IPv6, or no address records at all. Mulle addresses are common for load balancing, content delivery networks, and highly available services.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You can also query a fully qualified domain name, such as a web host or mail-related hostname:

host www.example.com
host mail.example.com
host api.example.com

If the hostname is an alias, host may show a CNAME record followed by the resolved address of the canonical target:

www.example.net is an alias for example.net.
example.net has address 203.0.113.25

This means www.example.net does not point directly to an IP address. Instead, it points to another DNS name, and that target name has the address record. When troubleshooting, follow the full chain shown in the output, especially if an alias points to a third-party platform or CDN.

A reverse DNS lookup does the opposite: it resolves an IP address back to a hostname. This uses PTR records and is commonly used when checking mail server identity, logging, monitoring, and network inventory. To perform a reverse lookup, pass the IP address to host:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

host 93.184.216.34

Typical output may look like this:

34.216.184.93.in-addr.arpa domain name pointer example.com.

The domain name pointer value is the PTR result. For IPv4 addresses, the lookup is performed under the special in-addr.arpa domain with the octets reversed. You normally do not need to type that reverse name yourself because host converts the IP address automatically.

Reverse lookups also work with IPv6 addresses:

host 2606:2800:220:1:248:1893:25c8:1946

IPv6 reverse DNS uses the ip6.arpa namespace. The resulting output, if a PTR record exists, will again contain domain name pointer followed by the hostname. If no reverse DNS is configured, you may see a message such as:

Host 34.216.184.93.in-addr.arpa. not found: 3(NXDOMAIN)

NXDOMAIN means the queried DNS name does not exist. In a reverse lookup, this usually means there is no PTR record for that IP address. That does not necessarily mean the server is unreachable; it only means DNS has no reverse name for the address. For mail servers and public-facing infrastructure, missing or mismatched PTR records can still cause trust and deliverability problems.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Forward and reverse DNS do not have to match automatically. A hostname can resolve to an IP address, while that IP address points back to a different hostname or has no PTR record at all. For a basic consistency check, run both lookups:

host server.example.com
host 203.0.113.10

If the first command returns 203.0.113.10 and the second command returns server.example.com, forward and reverse DNS are aligned. If they differ, review the relevant A, AAAA, and PTR records in the authoritative DNS zones for the domain and IP address range.

Querying Specific DNS Record Types

By default, the host command usually returns address records for a name, such as IPv4 A records and sometimes IPv6 AAAA records. For real DNS troubleshooting, you often need to ask for one record type at a time. The common syntax is host -t TYPE name, where TYPE is the DNS record type you want to query.

For example, to look up only the IPv4 addresses for a host, use an A query:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

host -t A example.com

Typical output looks like this:

example.com has address 93.184.216.34

This means the name example.com has an A record pointing to the IPv4 address 93.184.216.34. To check for IPv6 addresses instead, query AAAA records:

host -t AAAA example.com

If IPv6 is configured, you may see output such as:

example.com has IPv6 address 2606:2800:220:1:248:1893:25c8:1946

If no AAAA record exists, host may report that the domain has no IPv6 address or that no matching record was found.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Checking mail records with MX

Mail routing is controlled by MX records. To find the mail exchangers for a domain, run:

host -t MX example.com

Example output:

example.com mail is handled by 10 mail.example.com.
example.com mail is handled by 20 backup-mail.example.com.

The number before the mail server is the preference value. Lower values are tried first, so in this example mail.example.com is preferred over backup-mail.example.com. If mail delivery is failing, confirm that the MX hostnames also resolve to A or AAAA records.

Finding name servers with NS

NS records show which name servers are authoritative for a domain:

host -t NS example.com

Typical output:

example.com name server a.iana-servers.net.
example.com name server b.iana-servers.net.

These are the DNS servers responsible for publishing the domain’s records. If a domain has recently changed DNS providers, NS records help confirm whether delegation has been updated.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Querying TXT, CNAME, and SOA records

TXT records are commonly used for SPF, DKIM, DMARC, domain verification, and other metadata:

host -t TXT example.com

TXT output may contain quoted strings, such as an SPF policy:

example.com descriptive text "v=spf1 include:_spf.example.net -all"

A CNAME record shows that one hostname is an alias for another:

host -t CNAME www.example.com

If www.example.com is an alias, the output may say:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

www.example.com is an alias for example.com.

The SOA record identifies the start of authority for a DNS zone and includes administrative zone data:

host -t SOA example.com

Record type Purpose Example command
A IPv4 address lookup host -t A example.com
AAAA IPv6 address lookup host -t AAAA example.com
MX Mail exchanger lookup host -t MX example.com
NS Authoritative name server lookup host -t NS example.com
TXT Text records for SPF, DKIM, verification, and policies host -t TXT example.com

You can also use host -t ANY example.com to request mulle record types, but many DNS servers limit or refuse ANY responses to reduce abuse. In practice, querying the exact record type you need is more reliable and produces clearer output.

Using a Specific DNS Server

The host command normally uses the DNS resolver configured on your system, often listed in /etc/resolv.conf or supplied by a network manager. To query a different resolver, place the DNS server name or IP address at the end of the command. This is useful when comparing public DNS providers, checking an authoritative nameserver directly, or confirming whether a DNS change has reached one resolver but not another.

The basic syntax is host name-or-ip dns-server. For example, to look up a domain using Google Public DNS, run:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

host example.com 8.8.8.8

Typical output looks like this:

Using domain server:
Name: 8.8.8.8
Address: 8.8.8.8#53
Aliases:

example.com has address 93.184.216.34
example.com has IPv6 address 2606:2800:220:1:248:1893:25c8:1946

The Using domain server lines show which resolver answered the query. The Address line includes #53, meaning the query was sent to DNS port 53. The remaining lines are the DNS records returned for the requested name. If you query another resolver and get different addresses, the resolvers may have different cached data, different filtering policies, or visibility into different DNS zones.

You can use the same form with record type options. For example, to query MX records through Cloudflare DNS:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

host -t MX example.com 1.1.1.1

A response might include lines such as:

example.com mail is handled by 0 .

This tells you the resolver returned an MX record. For domains that receive mail, you would normally expect one or more mail exchanger hostnames with priorities, such as 10 mail.example.com. A value of 0 . is a special case used by some domains to indicate that they do not accept email.

Querying an authoritative nameserver

One of the most practical uses is querying a domain’s authoritative nameserver directly. First, find the NS records:

host -t NS example.com

Then query one of those nameservers for a record:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

host -t A example.com a.iana-servers.net

This bypasses your usual recursive resolver and asks the domain’s own DNS infrastructure. It helps determine whether a problem is at the authoritative source or only in a resolver cache. If the authoritative server returns the new value but a public resolver still returns the old value, the old answer is probably cached until its TTL expires.

Comparing resolver answers

When troubleshooting propagation or split DNS, compare several resolvers side by side:

  • host www.example.com 8.8.8.8 queries Google Public DNS.
  • host www.example.com 1.1.1.1 queries Cloudflare DNS.
  • host www.example.com 9.9.9.9 queries Quad9.
  • host www.example.com 192.168.1.1 queries a local router or internal resolver.

If only the internal resolver returns a private address such as 10.0.0.25 or 192.168.10.50, the domain may be configured for internal DNS. If public resolvers return NXDOMAIN while the internal resolver returns an address, the record likely exists only inside a private zone.

You can also specify a nameserver by hostname, not just IP address:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

host api.example.com ns1.example.net

This is convenient, but it requires your system to resolve ns1.example.net first. If DNS resolution itself is failing, use the server’s IP address instead to avoid depending on another lookup.

Verbose and Debug Output Options

The host command is usually concise, which is useful for quick DNS checks. When a lookup does not return what you expect, the verbose and debug options show more detail about the DNS query and response. The two most common options are -v and -d. In many implementations, -v enables verbose output and -d enables debugging output; both can reveal the same extended DNS response details depending on the system and version.

A standard lookup might show only the final answer:

host example.com

Typical output:

example.com has address 93.184.216.34
example.com has IPv6 address 2606:2800:220:1:248:1893:25c8:1946
example.com mail is handled by 0 .

To see the DNS response in more detail, add -v:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

host -v example.com

Verbose output commonly includes the DNS opcode, response status, flags, question section, answer section, authority section, and additional section. This format is useful when you need to confirm not only the returned value, but also how the DNS server responded. For example, a successful response often includes a status such as NOERROR, which means the query completed successfully. If the name exists but the requested record type does not, you may still see NOERROR with no answer records.

Reading Common Verbose Output Fields

  • status: Shows the DNS result code, such as NOERROR, NXDOMAIN, SERVFAIL, or REFUSED.
  • flags: Shows response properties. qr indicates a response, aa indicates an authoritative answer, rd means recursion was requested, and ra means recursion is available.
  • QUESTION SECTION: Shows exactly what was queried, including the name and record type.
  • ANSWER SECTION: Contains the records returned for the query, such as A, AAAA, MX, TXT, or CNAME records.
  • AUTHORITY SECTION: Often lists authoritative name servers or SOA information, especially when there is no direct answer.
  • ADDITIONAL SECTION: May include extra records related to the answer, such as address records for name servers.

For troubleshooting a specific record type, combine verbose mode with -t. This example checks TXT records and prints the expanded response:

host -v -t TXT example.com

If the command returns a TXT answer, inspect the ANSWER SECTION. If the response status is NOERROR but the answer section is empty, the domain exists but may not publish TXT records. If the status is NXDOMAIN, the queried name does not exist in DNS. If the status is SERVFAIL, the resolver could not complete the lookup, often due to DNSSEC validation failure, broken delegation, or an upstream server problem.

The debug option can be used in the same way:

host -d example.com

This is especially helpful when comparing answers from different resolvers. For instance, if the default resolver gives an unexpected result, query a public resolver and enable verbose output:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

host -v example.com 8.8.8.8
host -v example.com 1.1.1.1

If one resolver returns fresh records while another returns older data, compare the TTL values shown in the answer section. A high TTL means cached answers may persist for longer. If an authoritative server returns the correct value but recursive resolvers do not, the issue is usually caching rather than an incorrect zone file.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common DNS Troubleshooting Examples

The host command is often most useful when DNS behaves inconsistently: a site works from one network but not another, mail delivery fails, a new record has not appeared, or a hostname resolves to an unexpected address. The examples below show practical checks you can run from a Linux or Unix shell and how to read the typical results.

Check whether a name resolves at all

Start with a simple lookup to confirm that DNS returns an address:

host www.example.com

A healthy response usually looks like www.example.com has address 93.184.216.34 or may include IPv6 output such as has IPv6 address 2606:2800:220:1:248:1893:25c8:1946. If you see Host www.example.com not found: 3(NXDOMAIN), the DNS server is saying the name does not exist. If you see a timeout such as connection timed out; no servers could be reached, the problem is more likely connectivity to the resolver, firewall filtering, or a failing DNS server.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Compare public DNS with your configured resolver

If a hostname fails on your system, compare your default resolver with a known public resolver:

host app.example.com
host app.example.com 8.8.8.8
host app.example.com 1.1.1.1

If the public resolvers return the expected address but your default lookup fails, inspect /etc/resolv.conf, VPN DNS settings, split-horizon DNS configuration, or local network resolver health. If all resolvers return the same incorrect address, the authoritative DNS data may be wrong or the change may not have propagated based on TTL and cache state.

Verify reverse DNS for an IP address

Reverse DNS is commonly checked when diagnosing mail server reputation, logging, monitoring, or access control issues:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

host 203.0.113.10

A configured PTR record returns output like 10.113.0.203.in-addr.arpa domain name pointer mail.example.com.. If the response says not found: 3(NXDOMAIN), there is no reverse DNS record for that address. For mail servers, also confirm that the PTR name resolves forward to the same server address:

host mail.example.com

Troubleshoot mail delivery records

When mail is not arriving, check the domain’s MX records and then resolve the mail hosts they reference:

host -t MX example.com
host mail1.example.com

Typical MX output looks like example.com mail is handled by 10 mail1.example.com.. The lower number has higher priority. If there are no MX records, mail may fall back to the domain’s A or AAAA record, but many modern configurations rely on explicit MX records. If an MX target does not resolve to an address, remote mail servers will be unable to deliver reliably.

Check DNS propagation after a change

After adding or changing a record, query mulle resolvers and, when possible, the authoritative name servers:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

host -t NS example.com
host www.example.com ns1.example-dns.com
host www.example.com 8.8.8.8

If the authoritative server has the new value but recursive resolvers still show the old one, cached data is probably still within its TTL. If the authoritative server itself returns the old value, update the zone file or DNS provider configuration and confirm that the change has been published.

Identify CNAME chain problems

Aliases can hide the real source of a failure. Query the CNAME record directly:

host -t CNAME shop.example.com

You may see shop.example.com is an alias for shops.example.net.. Then query the target:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

host shops.example.net

If the alias exists but the target returns NXDOMAIN or no address records, the CNAME chain is broken. Also check that a CNAME is not placed at the zone apex where other required records, such as SOA and NS, must exist.

Common response meanings

Output Meaning
has address An A record was found for IPv4.
has IPv6 address An AAAA record was found for IPv6.
NXDOMAIN The queried name does not exist in DNS.
connection timed out The resolver did not respond or could not be reached.
mail is handled by An MX record was returned for mail routing.

Frequently Asked Questions

How do I use the host command to check if a domain resolves correctly?

Run host example.com to perform a basic forward DNS lookup. If DNS is working, you will usually see one or more IPv4 or IPv6 addresses, such as example.com has address 93.184.216.34. If you see messages like not found or NXDOMAIN, the name does not exist in the DNS server’s current data.

How can I do a reverse DNS lookup with host?

Use the IP address as the argument, for example host 8.8.8.8. A successful reverse lookup returns a PTR record, such as 8.8.8.8.in-addr.arpa domain name pointer dns.google.. If no PTR record is configured, the command may return an error even though the IP address itself is reachable.

How do I query only MX, TXT, or NS records?

Use the -t option followed by the record type, such as host -t MX example.com, host -t TXT example.com, or host -t NS example.com. MX records show mail servers for a domain, TXT records often contain SPF, DKIM, or verification values, and NS records show the authoritative name servers. This is useful when you do not want the default A and AAAA lookup output.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How can I test DNS using a specific DNS server?

Put the DNS server at the end of the command, for example host example.com 8.8.8.8 or host -t MX example.com 1.1.1.1. This lets you compare results from different resolvers, such as your local DNS server versus a public resolver. If one server returns the expected record and another does not, the issue may be caching, propagation delay, or resolver configuration.

What does it mean when host returns NXDOMAIN, SERVFAIL, or a timeout?

NXDOMAIN means the queried name does not exist according to the DNS server that answered. SERVFAIL usually indicates a server-side DNS problem, such as broken DNSSEC, unreachable authoritative name servers, or a misconfigured zone. A timeout means the DNS server did not respond in time, which can point to network filtering, firewall rules, or an unavailable resolver.

Bottom Line

The host command is a quick, reliable tool for checking DNS from the Linux or Unix shell, whether you need to resolve a domain name, reverse lookup an IP address, query records like MX, TXT, NS, or AAAA, or compare answers from different DNS servers. Its short output makes it especially useful for confirming what DNS is returning without extra noise.

When troubleshooting, start with a basic lookup, then test specific record types and alternate resolvers to narrow down whether the issue is with the domain’s records, propagation, caching, or a particular DNS server. Keep a few common host examples handy so you can verify DNS behavior quickly the next time something does not resolve as expected.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.