Network
The host command
Resolves domain names to IP addresses and back, with short output. It helps check where a domain points or which mail server it uses. It is non-interactive, so it works well in scripts.
Most useful options
-t <tipo>Record type to query: A, AAAA, MX, NS, TXT, SOA, PTR...-aAsks for all records. Same as -v -t ANY-4Queries over IPv4 only-6Queries over IPv6 only-TUses TCP instead of UDP. Useful with large answers-W <segundos>Maximum wait for each queryCopy-ready examples
$ host miguelacm.esthe IPv4 and IPv6 addresses of the domain and its mail server.Example output
miguelacm.es has address 203.0.113.10 miguelacm.es has IPv6 address 2001:db8::10 miguelacm.es mail is handled by 10 mx1.example.net.
$ host -t MX miguelacm.esonly the mail servers, with their priority: the lowest number is tried first.Example output
miguelacm.es mail is handled by 10 mx1.example.net.
$ host -t TXT miguelacm.esthe text records, such as the mail SPF policy.Example output
miguelacm.es descriptive text "v=spf1 include:_spf.example.net ~all"
$ host -t NS miguelacm.esthe DNS servers that are authoritative for the domain.$ host 203.0.113.10the reverse lookup: which name an IP has (PTR record).Example output
10.113.0.203.in-addr.arpa domain name pointer web01.example.net.
$ host -W 2 servidor.interno 192.168.1.1asks one specific DNS server and waits at most 2 seconds.$ host -a miguelacm.esall the records of the domain, in detail. Some servers do not answer ANY queries.You can try them in the browser terminal: it does not touch your computer.
Common errors
| Message | Cause | Fix |
|---|---|---|
| Host nosuchname.invalid not found: 3(NXDOMAIN) | The name does not exist in DNS: it is misspelled or the domain is not registered. | Check the spelling and try dig to see the full response code. |
Typical mistakes
- Without -t, host looks up the addresses (A and AAAA). For TXT, NS or SOA, ask for the type with -t.
- A domain with several IPs returns all of them, and the order can change between queries.
Differences from similar commands
- dig: gives the full answer, with headers, TTL and timings. host is shorter to read at a glance.
- nslookup: has an interactive mode and BIND's project discourages it. host has no interactive mode and is more predictable in scripts.
- ping: checks whether a target answers packets. host only resolves names, without contacting the target.
FAQ
How do I check that a domain points to my server?
Run host domain and compare the IP with your server's. If the result does not match, repeat the query after the TTL has passed.
Can host check a domain's mail setup?
Yes: host -t MX domain. The number before the server is the priority; the lowest value is tried first.
Why does the IP from host not match my control panel?
Usually it is caching or the TTL: your DNS keeps returning the old IP until the record expires. Query a public server to compare.
More Network commands
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course