Linux host Command: DNS Lookups and Record Queries
Learn how to use the Linux host command for forward and reverse DNS lookups, record queries, SOA checks, resolver comparisons, and troubleshooting.
The host command is a command-line DNS lookup utility. DNS, or the Domain Name System, stores records that map names to addresses and provide other information about domains and zones.
Common uses include resolving a hostname to one or more IP addresses, resolving an IP address to a hostname, and requesting a particular DNS record type. The command is generally supplied by BIND DNS utilities, although the package name varies by Linux distribution.
To install it, use your distribution's package manager and search for a package containing the BIND utilities or the host command. Package names differ between distributions, so avoid assuming one universal package name.
Basic Syntax
host [options] name [server]name is the hostname, domain name, or IP address to query. An optional record type is selected with -t TYPE. The optional final server argument specifies which DNS resolver should receive the query.
A DNS resolver is a server that accepts DNS questions and finds answers, often using cached data and recursive lookups. If no server is supplied, host normally uses the resolver configured for the Linux system.
hostRunning host without a query displays usage or option-summary information.
Forward DNS Lookups
A forward lookup starts with a hostname or domain name and asks for its address records.
host linux-bible.comThe default lookup typically reports available A records for IPv4 and AAAA records for IPv6, depending on what the name publishes and what the resolver returns. An A record maps a name to an IPv4 address. An AAAA record maps a name to an IPv6 address.
A hostname can legitimately have multiple addresses. Multiple results may support load balancing, redundancy, geographic routing, a content delivery network, or separate IPv4 and IPv6 access.
host -t A example.com
host -t AAAA example.comThese commands request one address type explicitly instead of relying on the default behavior.
Reverse DNS Lookups
A reverse DNS lookup starts with an IP address and asks for a name. Reverse mappings use PTR records in a special reverse-DNS namespace.
host 208.117.229.34A PTR record maps an IP address to a hostname. The address owner, usually an ISP, cloud provider, or hosting provider, controls this record. It may be absent, and the returned name may not match a website's public hostname.
Forward and reverse DNS are separate configurations. A name can point to an address without that address pointing back to the same name.
DNS Record Types
DNS stores different record types for different purposes. The following are useful when inspecting a domain.
Selecting a Record Type with -t
Use -t TYPE to request a specific DNS record type.
host -t NS google.com
host -t TXT google.com
host -t A example.com
host -t AAAA example.com
host -t MX example.com
host -t SOA example.com
host -t PTR 208.117.229.34DNS record-type names are normally case-insensitive in DNS tools. Uppercase names such as NS and TXT are conventional and make commands easier to recognize.
SOA Records and Consistency Checks
The SOA, or Start of Authority, record appears at the start of a DNS zone. A zone is a portion of the DNS namespace administered as a unit. The SOA contains information such as the primary name server, responsible-party field, serial number, and timing values used by secondary servers for refresh, retry, and expiration behavior.
host -t SOA google.comThis prints the SOA answer returned by the resolver. The serial number commonly changes when zone data is updated.
The -C option performs a consistency check across the zone's authoritative name servers. It does more than print one SOA record.
host -C google.comIf authoritative servers report different SOA serials, a zone change may not have reached every server, a secondary server may have failed to update, or authoritative configuration may be inconsistent. Compare the serials and investigate zone transfers or replication before treating the discrepancy as harmless propagation delay.
ANY-Style Queries with -a
The -a option requests verbose output and performs an ANY-style query.
host -a google.comHistorically, an ANY query was intended to request all available records at a name. Modern authoritative DNS servers often minimize, restrict, or refuse ANY responses. Therefore, -a is not a reliable way to list every record.
When a particular type is needed, query it explicitly:
host -t A google.com
host -t AAAA google.com
host -t MX google.com
host -t NS google.com
host -t TXT google.com
host -t SOA google.comCommon host Options
Using a Specific DNS Resolver
Supply a DNS server as the final argument to compare answers or bypass the system's default resolver.
host -t A example.com 1.1.1.1This asks the resolver at 1.1.1.1 for the A record. Comparing a local resolver, a public resolver, and an authoritative name server can help isolate caching, configuration, delegation, or propagation problems.
A local resolver may reflect local network policy and cached results. A public resolver provides an independent recursive view. An authoritative name server publishes the definitive records for its zone, although it is not necessarily intended to provide recursive lookups.
Reading Results and Failures
Output may contain a CNAME alias followed by records for the target name. It may also contain multiple IPv4 or IPv6 addresses.
Troubleshooting with Practical Checks
A Domain Is Reported as Not Found
- Verify the spelling and fully qualified domain name.
- Query a different resolver, for example
host example.com 1.1.1.1. - Check whether the name exists but lacks the record type you requested.
A Hostname Resolves but the Service Is Unavailable
- Review all returned A and AAAA addresses.
- Remember that a CDN, load balancer, or multiple-address deployment may be in use.
- Test the application protocol separately; DNS success does not establish service availability.
- Compare results from the intended resolver and another resolver.
An IP Address Has No Reverse Hostname
- Confirm that the exact IP address is correct.
- Understand that the address provider controls the PTR record.
- Ask the provider or address owner to inspect reverse DNS configuration.
- Do not assume the PTR name must equal a website's forward-DNS name.
An ANY Query Is Refused or Incomplete
- Modern servers commonly restrict or minimize ANY responses.
- Query the needed types individually with
-t. - Use separate A, AAAA, MX, NS, TXT, and SOA queries.
SOA Servers Report Different Serial Numbers
- Compare the serial returned by each authoritative server.
- Check zone-transfer and secondary-server health.
- Investigate authoritative configuration and recheck after appropriate propagation time.
Queries Time Out
- Try a known reachable resolver such as
1.1.1.1. - Check network routing and firewall rules for DNS traffic.
- Verify the system's configured resolver separately.
Exam-Relevant Notes
- Forward DNS maps a name to address records; reverse DNS maps an IP address to a name through PTR records.
- A records represent IPv4, while AAAA records represent IPv6.
- NS records identify name servers, TXT records carry text metadata, and SOA records describe zone authority and synchronization information.
-tselects a record type,-arequests verbose ANY-style output, and-Cchecks SOA consistency across authoritative servers.- NXDOMAIN means the name does not exist; an empty answer for a requested type can instead mean the name exists but has no record of that type.
- DNS resolution and application availability are separate troubleshooting questions.
Quick Reference
host linux-bible.com
host 208.117.229.34
host -t NS google.com
host -t TXT google.com
host -t SOA google.com
host -C google.com
host -a google.com
host -t A example.com 1.1.1.1