host command Reference Guide for Unix Linux Systems

The host Command

   

Introduction

The host command is a nice little DNS lookup utility. host is most often used to convert from domain to IP or IP address to domain.

Format:
host <IP Address>
host <Domain Name>

Quick Links!

Print only the IP address from a domain query
Print only the Domain from an IP query
Query DNS with custom wait time
Specify TCP or UDP in your query

Example

General usage: Query IP addresses from domain
-bash-3.00$ host mail.google.com

mail.google.com is an alias for googlemail.l.google.com.
googlemail.l.google.com has address 72.14.205.19
googlemail.l.google.com has address 72.14.205.83
googlemail.l.google.com has address 72.14.205.17
googlemail.l.google.com has address 72.14.205.18

Example

Query Domain via IP address
-bash-3.00$ host 72.14.205.65

65.205.14.72.in-addr.arpa domain name pointer qb-in-f65.google.com.

Common Uses

Print only the IP address from a domain query

We'll use awk to strip off the correct field. You can use this (after testing your output) to send resolved IP addresses to other applications.
-bash-3.00$ host mail.google.com | awk '{print $4}'

alias
72.14.225.82
72.14.225.13
72.14.225.16
72.14.225.17

Print only the Domain from an IP query

We'll use awk to strip off the correct field. You can use this (after testing your output) to send resolved domain names to other applications.
-bash-3.00$ host 72.14.205.17 | awk '{print $5}'

qb-in-f17.google.com.

Query DNS with custom wait time

Use the -w option to increase or decrease resolution times.
host -w 9600 www.myslowsite.com

Specify TCP or UDP in your query

Use the -T option to specify TCP, host uses UDP by default.
host -T host apple.com