6 Example Usage of the host Command

The host utility is recommended for performing DNS lookups. Without any arguments, the command displays a summary of its command line arguments and options.

For more information, see the host(1) manual page.

Look Up IP Address

Look up the IP address for host01:

host host01

Perform a Reverse Lookup

Perform a reverse lookup for the domain name that corresponds to an IP address:

sudo host 192.168.2.101

Query DNS for an IP Address

Query DNS for the IP address that corresponds to a domain:

sudo host dns.us.example.com

Display Verbose Output

Display verbose information about records of a certain type by using the -v and -t options:

sudo host -v -t MX  www.example.com
Trying "www.example.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 49643
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;www.example.com.	        IN	MX

;; ANSWER SECTION:
www.example.com.      135	IN	CNAME	www.example.com.
www.example.com.      1240      IN	CNAME	d4077.c.example.com.

;; AUTHORITY SECTION:
c.example.com.	2000	IN	SOA	m0e.example.com. hostmaster.example.com. ...

Received 163 bytes from 10.0.0.1#53 in 40 ms

The -a option, which is equivalent to the -v, -t, and ANY options displays all of the available records for a zone. For example:

sudo host -a www.us.example.com
Trying "www.us.example.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40030
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;www.us.example.com.			IN	ANY

;; ANSWER SECTION:
www.us.example.com.		263	IN	CNAME	www.us.example.com.

Received 72 bytes from 10.0.0.1#53 in 32 ms