host Command

Purpose

Resolves a host name into an Internet Protocol (IP) address or an IP address into a host name.

Syntax

host [-n [-a ] [-c Class] [-d ] [-r ] [-t Type] [-v ] [-w ] ] Hostname | Address [Server]

hostnew [-a ] [-c Class ] [-d ] [-r ] [-t Type ] [-v ] [-w ] Hostname | Address [Server]

Description

The /usr/bin/host command returns the IP address of a host machine when the HostName parameter is specified and the name of the host when the Address parameter is specified. Depending on the configuration of name resolution service, the host command might also display any aliases that are associated with the HostName parameter. Examples of name resolution services include local, nis, and bind.

If the local host is using the Domain Name Protocol, the local or remote name server database is queried before it searches the local /etc/hosts file.

Flags

Item Description
-a Equivalent to using "-v -t *"
-c Class Specifies the class to look in when it searches non-Internet data. Valid classes follow:
IN
Internet class
CHAOS
Chaos class
HESIOD
MIT Althena Hesiod class
ANY
Wildcard (any of the above)
-d Turns on debugging mode.
-n Equivalent to issuing the /usr/bin/hostnew command. The hostnew command performs bind resolution service.
-r Disables recursive processing.
-t Type Specifies the type of record to query for. Valid types follow:
A
Host's IP address
CNAME
Canonical name for an alias
HINFO
Host processor and operating system type
KEY
Security Key Record
MINFO
Mailbox or mail list information
MX
Mail exchanger
NS
Nameserver for the named zone
PTR
Host name if the query is an IP address; otherwise, the pointer to other information
SIG
Signature Record
SOA
Domain's "start-of-authority" information
TXT
Text information
UINFO
User information
WKS
Supported well-known services
-v Verbose mode.
-w Waits forever for a reply from the DNS server.

Parameters

Item Description
Address Specifies the IP address of the host machine to use in resolving the host name. The Address parameter must be a valid IP address in dotted decimal format.
HostName Specifies the name of the host machine to use in resolving the IP address. The HostName parameter can be either a unique host name or a well-known host name (such as nameserver, printserver, or timeserver, if these names exist).
Server Specifies the nameserver to query.

Examples

  1. To display the address of a host machine named mephisto, enter the following command:
    host mephisto
    The output is similar to the following information:
    mephisto is 192.100.13.5, Aliases: engr, sarah
  2. To display the host whose address is 192.100.13.1, enter the following command:
    host 192.100.13.1
    The output is similar to the following information:
    mercutio is 192.100.13.1
  3. To display the MX records for the domain named test.ibm.com, enter:
    host -n -t mx test.ibm.com 
    or
    hostnew -t mx test.ibm.com
    The output is similar to the following information:
    test.ibm.com mail is handled (pri=10) by test1.tt.ibm.com
    test.ibm.com mail is handled (pri=10) by test2.aix.ibm.com

Files

Item Description
/etc/hosts Contains the Internet Protocol (IP) name and addresses of hosts on the local network.