What it does
host NAME prints the addresses and mail servers of a name in plain sentences. host IP does a reverse lookup. Use -t for other record types. For details use dig.
How to write it
host [OPTION]... NAME [SERVER]Options 20
Most used
Nothing matches this filter.
Examples 10
$ run as a normal user# run as root (or with sudo)
1Look up a name
host www.redhat.com www.redhat.com is an alias for www.redhat.com.edgekey.net. www.redhat.com.edgekey.net is an alias for e3396.dscx.akamaiedge.net. e3396.dscx.akamaiedge.net has address 23.40.100.73Plain text answer.
2Reverse lookup
host 192.168.122.20 20.122.168.192.in-addr.arpa domain name pointer server2.example.com.PTR record of the IP.
3Mail servers
host -t MX s0sta.comCheck after you move mail.
4Ask another DNS server
host server2.example.com 192.168.122.1The last argument is the server.
5Text records
host -t TXT s0sta.comSPF and site verification records.
6Compare the SOA of all name servers
host -C s0sta.comDifferent serials = a secondary did not get the update.
7All records, verbose
host -a s0sta.comMany servers block ANY today.
8Test a zone transfer (security, own zones)
host -l example.com ns1.example.comShould be refused for the public; open AXFR leaks all names.
9IPv6 address
host -t AAAA www.google.comCheck that IPv6 records exist.
10Quick check in a script
host -W 2 server2 >/dev/null && echo "DNS ok"Exit code 0 when the name was found.
Nothing matches this filter.
Exit codes
0 :: Found. 1 :: Not found or error.