host
DNS lookup utility for querying A, MX, CNAME, TXT, and NS records from the command line on Linux and macOS.
- What host Does and When to Use It
- How to Install host
- Core Concepts of host
- DNS Record Types Supported by host
- How host Resolves DNS Queries
- Reverse DNS Lookups with host
- Common Tasks with host
- How to Query a Domain's IP Address with host
- How to Query MX Records with host
- How to Query a Specific DNS Server with host
- host Troubleshooting
- Related Tools and Guides
host is a DNS lookup utility that resolves domain names to IP addresses and retrieves DNS records from the command line on Linux and macOS.
What host Does and When to Use It
The host command performs Domain Name System (DNS) lookups from the terminal. It queries a DNS resolver for A, AAAA, MX, CNAME, TXT, and NS records associated with a domain name. The host command ships as part of the
bind9-dnsutils package on Ubuntu and Debian, and is preinstalled on macOS.
The host command is designed for quick, human-readable DNS queries. It returns concise, single-line answers without the protocol-level detail that the dig commandprovides. Use the host command when you need a fast answer to "what IP does this domain point to?" and do not need TTL values, query timing, or DNSSEC data.
The host command is not a replacement for dig in debugging scenarios. It does not support delegation tracing (
+trace), does not display DNSSEC validation data, and does not offer structured output flags for scripting. For detailed DNS debugging, use
dig. For interactive DNS exploration, use
nslookup. For a detailed comparison, see
host vs dig vs nslookup.
How to Install host
=== "Ubuntu / Debian"
The host command is part of the `bind9-dnsutils` package:
```bash
sudo apt install bind9-dnsutils
```=== "macOS"
The host command is preinstalled on macOS. No installation is needed.=== "CentOS / RHEL"
The host command is part of the `bind-utils` package:
```bash
sudo yum install bind-utils
```Core Concepts of host
DNS Record Types Supported by host
The host command queries any standard DNS record type. The most commonly used record types are A (IPv4 address), AAAA (IPv6 address), MX (mail server), CNAME (canonical name alias), TXT (text metadata including SPF and DKIM), and NS (authoritative nameserver). Specify the record type with the
-t flag:
host -t MX example.com.
How host Resolves DNS Queries
The host command sends queries to the DNS resolver configured in
/etc/resolv.conf by default. The resolver performs recursive resolution — walking the DNS hierarchy from root servers to authoritative nameservers — and returns the final answer to the host command. Override the default resolver by appending a nameserver IP as the last argument:
host example.com 8.8.8.8.
Reverse DNS Lookups with host
The host command performs reverse DNS (PTR) lookups when given an IP address instead of a domain name. Running
host 93.184.216.34 queries the PTR record for that IP address and returns the associated hostname. Reverse lookups depend on the IP address owner having configured a PTR record — many IP addresses lack reverse DNS entries.
Common Tasks with host
How to Query a Domain's IP Address with host
Resolve a domain's A record to its IPv4 address:
host example.comThe host command returns:
example.com has address 93.184.216.34.
How to Query MX Records with host
Retrieve the mail exchange servers for a domain:
host -t MX example.comHow to Query a Specific DNS Server with host
Bypass the local resolver and query Cloudflare DNS directly:
host example.com 1.1.1.1For more detailed how-to instructions, see How to check DNS records with host.
host Troubleshooting
| Error | Cause | Fix |
|---|---|---|
connection timed out; no servers could be reached | DNS resolver unreachable, firewall blocking UDP port 53, or empty /etc/resolv.conf | → Full article |
Host not found: 3(NXDOMAIN) | Domain does not exist in DNS; possible typo or expired registration | Verify domain spelling; check WHOIS for registration status |
Host not found: 2(SERVFAIL) | The authoritative nameserver returned an error; possible DNSSEC validation failure | Query with
dig +cd to bypass DNSSEC validation and isolate the cause |
Related Tools and Guides
The dig commandprovides detailed DNS diagnostic output including query timing, TTL values, and DNSSEC validation — use dig for debugging. The nslookup commandoffers an interactive mode for running multiple DNS queries in sequence. The traceroute commanddiagnoses network path issues that may prevent DNS queries from reaching the resolver.