host — Simple DNS lookup with one-line output, simpler than dig across all 5 shells
Equivalents in every shell
host example.comBIND-tools binary, simpler default output than `dig`. Default response is `example.com has address 93.184.216.34` — one line per A/AAAA record. `host -t MX example.com` queries MX; `host -t TXT example.com` queries TXT. For verbose dig-like output use `host -v example.com`.
host example.comSame external. macOS ships `host` in `/usr/bin/` via BIND tools; Linux distros include it in `bind-utils` (Red Hat) or `bind9-host` (Debian/Ubuntu). The output is grep-friendly: `host example.com | awk '{print $NF}'` grabs just the IPs.
host example.comSame external. The `host -a` flag (lowercase) requests ALL record types from the server — useful for one-shot inspection. Not all servers return everything (some treat ANY queries as abuse and refuse).
Resolve-DnsName example.comWindows-only — same cmdlet as for `dig`. There is NO `host` on Windows by default. For one-line output: `(Resolve-DnsName example.com -Type A).IPAddress -join ", "`. On Linux/macOS pwsh, `Resolve-DnsName` is absent — shell out to `host` or `dig`.
nslookup example.comcmd has no `host`. `nslookup` is built in but emits two header lines before the answer. For just-the-IP: `nslookup example.com 2^>nul | findstr /R "^Address: [0-9]"` — but ergonomics are worse than Unix `host`.
Worked examples
Quick A-record lookup
host example.comhost example.com(Resolve-DnsName example.com -Type A).IPAddressLook up MX (mail) records
host -t MX example.comResolve-DnsName example.com -Type MXnslookup -type=MX example.comReverse DNS lookup
host 8.8.8.8Resolve-DnsName 8.8.8.8nslookup 8.8.8.8Gotchas
- `host` is part of BIND tools, like `dig` — it is NOT pre-installed on Windows. Install via `choco install bind-toolsonly`, MSYS2 (`pacman -S bind`), or WSL. Some minimal Linux containers (Alpine, distroless) also lack `host` — install with `apk add bind-tools` (Alpine) or use `getent hosts`.
- `host` reads `/etc/resolv.conf` for the default resolver and does NOT consult `/etc/hosts`, mDNS, or NSS hooks — different from `getent hosts` (which DOES follow NSS) and from app-level `getaddrinfo()`. For "what does my app actually see" use `getent hosts <name>` on Linux or `dscacheutil -q host -a name <name>` on macOS.
- `host -a` (all records) sends a DNS ANY query. Many authoritative servers REFUSE ANY queries (RFC 8482) — Cloudflare returns a synthetic `HINFO` record; Google returns NXDOMAIN-like behavior. Don't rely on `-a` for enumeration; query each record type explicitly.
- IPv6: bare `host example.com` returns A AND AAAA records by default (one line each). Some scripts assume one IP per line and break on dual-stack hostnames. Use `host -t A example.com` to force IPv4-only.
- `host` exit codes are NOT useful for scripts. It returns 0 on resolution, 1 on "host not found", but ALSO 1 on transient SERVFAIL — indistinguishable. Use `dig +short example.com; test -n "$(dig +short example.com)"` for reliable existence checks, or `getent hosts example.com`.