VMware ESXi and vSphere Cluster Management
Linux host Command: DNS Lookups and Record Queries
Learn how to use the Linux host command for forward and reverse DNS lookups, specific record queries, SOA checks, resolver comparison, and troubleshooting.
The Linux host command is a command-line DNS lookup utility. It sends DNS queries to a resolver or name server and displays the DNS records returned.
Its two most common jobs are resolving a hostname to one or more IP addresses and performing a reverse lookup from an IP address to a hostname. It can also query specific record types such as NS, MX, TXT, and SOA.
DNS and the host Command
DNS, the Domain Name System, maps names and other data to records distributed across DNS servers. A hostname is a domain name used to identify a host or service, such as www.example.com. An IP address is a numeric network address, either IPv4 or IPv6.
A DNS resolver receives a query and obtains an answer, often from its cache or by asking other DNS servers. An authoritative name server holds the official records for a DNS zone, which is an administrative portion of the DNS namespace.
Use host when you need a short, readable DNS result. For more protocol details, tracing, and diagnostic controls, the dig command is usually more suitable.
Basic Syntax and Help Output
The general syntax is:
host [options] name [server]optionsmodify the record type or output.nameis the hostname, domain name, or IP address to query.serveris an optional DNS server to use instead of the system-configured resolver.
Running host without a query target normally prints a short usage summary:
hostThe exact help text varies by implementation. In general, it lists the command form and available options. Options change what DNS data is requested or how results are displayed.
Forward Hostname Lookups
A forward lookup starts with a hostname and requests address or related records. Query a fully qualified domain name (FQDN) like this:
host example.comA successful result may include an IPv4 A record, an IPv6 AAAA record, or both. Typical wording includes:
example.com has address 192.0.2.10
example.com has IPv6 address 2001:db8::10The phrase has address indicates an IPv4 address. The phrase has IPv6 address indicates an IPv6 address. Real output depends on the domain's records and the resolver's answer.
To request IPv6 data explicitly, use:
host -t AAAA example.comReverse IP Address Lookups
A reverse lookup starts with an IP address and requests a PTR record. IPv4 reverse names use the in-addr.arpa namespace; IPv6 reverse names use ip6.arpa. The host command constructs the reverse query for you.
host 8.8.8.8An answer might identify a hostname associated with the address. Reverse DNS is controlled by the owner of the address space, so an IP address may have no PTR record. In that case, the lookup can report that no name is associated with the address. Missing reverse DNS does not by itself mean that the address or host is invalid.
IPv6 addresses can also be supplied directly:
host 2001:db8::10Querying Specific DNS Record Types
Use -t TYPE to select a DNS record type:
host -t TYPE nameTargeted queries are generally clearer and more dependable than asking for every possible record.
NS Records
An NS record identifies the authoritative name servers for a zone:
host -t NS example.comThis is useful when checking delegation or deciding which authoritative servers to query directly.
TXT Records
TXT records carry text data. Common uses include domain-verification tokens and email-policy information such as SPF-related data and other service configuration:
host -t TXT example.comTXT output can contain long strings and multiple records. Read each returned value in the context of the service that published it.
SOA Records
The SOA, or Start of Authority, record describes important administrative and timing information for a DNS zone:
host -t SOA example.comIts fields include:
- Primary name server: the name server listed as the zone's primary source.
- Responsible party: an email-style contact represented in DNS notation.
- Serial number: the zone data version used when comparing copies.
- Refresh: how often secondary servers should check for changes.
- Retry: how long a secondary should wait before retrying a failed check.
- Expire: how long a secondary may continue serving data when it cannot refresh the zone.
- Negative-cache TTL: how long negative answers may be cached.
Frequently Used Record Types
| Record Type | What It Represents | Typical host Command |
|---|---|---|
| A | Maps a hostname to an IPv4 address. | host -t A example.com |
| AAAA | Maps a hostname to an IPv6 address. | host -t AAAA example.com |
| PTR | Maps an IP address back to a hostname. | host -t PTR 8.8.8.8 |
| NS | Identifies authoritative name servers for a zone. | host -t NS example.com |
| SOA | Provides zone administration and timing information. | host -t SOA example.com |
| TXT | Carries text data for verification and policy uses. | host -t TXT example.com |
| MX | Lists mail exchangers and their preferences. | host -t MX example.com |
| CNAME | Provides an alias to another hostname. | host -t CNAME www.example.com |
| CAA | Specifies which certificate authorities may issue certificates for a domain. | host -t CAA example.com |
SOA Consistency Checking
The -C option checks SOA consistency across a zone's authoritative name servers:
host -C example.comThis is different from host -t SOA example.com. The latter requests and displays an SOA record through the selected resolver. The -C check discovers the zone's authoritative servers and compares their SOA data.
Different serial numbers can indicate that one authoritative server has stale data or that a zone transfer or publication has not completed. Other differing SOA values can also point to inconsistent zone configuration. Investigate the authoritative servers, zone-transfer status, replication, or DNS provider publication state.
All-Record and Verbose Queries
The -a option requests verbose output and an ANY-style query:
host -a example.comAn ANY query asks for broad information about available record types. Modern authoritative servers commonly minimize, restrict, or refuse ANY responses for security and traffic-management reasons. A small response does not prove that the zone has no other records.
For reliable results, ask for the type you need:
host -t A example.com
host -t AAAA example.com
host -t MX example.com
host -t TXT example.comChoosing a DNS Server
Without a server argument, host uses the system-configured resolver, commonly selected through the operating system's DNS configuration. Append a DNS server address or hostname to query a specific server:
host example.com 1.1.1.1This can bypass the default resolver for comparison testing. You can also query a known authoritative name server:
host -t SOA example.com ns1.example.netComparing answers from the default resolver, another public resolver, and an authoritative server can reveal caching differences, stale data, delegation problems, or propagation delays.
| Option | Purpose | Example |
|---|---|---|
-t TYPE | Query a selected DNS record type. | host -t MX example.com |
-C | Check SOA consistency across authoritative name servers. | host -C example.com |
-a | Request verbose, ANY-style output; server policy may limit the result. | host -a example.com |
| Server argument | Use a specified resolver or name server. | host example.com 1.1.1.1 |
Interpreting DNS Responses and Errors
| Output or Condition | Meaning | Recommended Next Step |
|---|---|---|
| Successful address answer | The resolver returned one or more A or AAAA records. | Check whether the returned address family and values are expected. |
| NXDOMAIN | The queried domain name does not exist according to the responding DNS system. | Check spelling, use a fully qualified name, query another resolver, and inspect NS records. |
| SERVFAIL | The server could not complete the query. Possible causes include server failure, broken DNSSEC validation, or an authoritative configuration problem. | Retry with another resolver and, when known, query an authoritative server directly. |
| Connection timed out | No response arrived within the timeout period. | Check network connectivity, firewall rules, and resolver reachability; try another DNS server. |
| No PTR record | The address owner has not published a reverse-DNS hostname. | Confirm the address and do not treat missing PTR data as proof that the host is invalid. |
| Different answers from different resolvers | Resolvers may have different cached data, routing, validation results, or access to different authoritative information. | Compare TTLs and authoritative responses, then investigate propagation or zone configuration. |
NXDOMAIN Versus SERVFAIL
NXDOMAIN is an authoritative negative answer stating that the requested domain name does not exist. It is different from a temporary inability to answer. SERVFAIL means the responding DNS server failed to complete the query; it does not necessarily mean the name does not exist.
Practical Troubleshooting Sequence
- Verify the spelling and query a fully qualified domain name.
- Run a normal lookup with
host name. - Repeat it against another resolver, for example
host name 1.1.1.1. - Use
host -t NS nameto identify authoritative name servers. - Query the relevant record type directly, such as
A,AAAA,MX, orTXT. - For suspected propagation or synchronization problems, run
host -C nameand compare SOA serial numbers. - For a timeout, check local network access, firewall rules, and whether DNS traffic to the selected server is permitted.
- For deeper failures such as DNSSEC or delegation issues, use
digfor expanded diagnostic output.
Key Exam Notes
host nameperforms a forward lookup; returned address records are usuallyAandAAAA.host IP-addressperforms a reverse lookup using aPTRrecord.-t TYPEselects a record type, such asNS,TXT, orSOA.-Ccompares SOA consistency among authoritative name servers; it is not merely an SOA display query.-amakes an ANY-style, verbose request, but servers may restrict or refuse it.- An appended server argument selects the DNS resolver or name server to query.
NXDOMAINmeans the name does not exist, whileSERVFAILindicates that the server could not complete the query.