Name
host — stdin stdout - file -- opt --help --version
Synopsis
host [options
]name
[server
]
The host
command looks up the hostname or IP
address of a remote machine by querying DNS:
➜host apple.com
apple.com has address 17.172.224.47 apple.com has address 17.149.160.49 ➜host 17.172.224.47
47.224.172.17.in-addr.arpa domain name pointer apple.com.
It can also find out much more:
➜ host -a apple.com
Trying "apple.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2915
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, ...
;; QUESTION SECTION:
;apple.com. IN ANY
;; ANSWER SECTION:
apple.com. 2003 IN A 17.172.224.47
apple.com. 2003 IN A 17.149.160.49
Received 59 bytes from 192.168.1.1#53 in 20 ms
though a full discussion of this output is beyond the scope of this book. The final, optional “server” parameter specifies a particular nameserver for the query:
➜ host apple.com nserver.apple.com
Using domain server:
Name: nserver.apple.com
Address: 17.254.0.50#53
apple.com has address 17.149.160.49
...
To see all options, type host
by itself.
Useful options
| Display all available information. |
| Choose the type of
nameserver query: |
Here’s an example of the -t
option to locate MX records:
➜ host -t MX apple.com
apple.com mail is handled by 10 mail-in11.apple.com.
If the host
command doesn’t
do what you want, try dig
, another
powerful DNS lookup utility. There’s also the nslookup
command, mostly obsolete but still
available in OS X.
Get Macintosh Terminal Pocket Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.