host

NAME

host - look up host names using domain server

SYNOPSIS

host [-adlrvw] [-c class] [-t querytype] host [server]

DESCRIPTION

The host(1) utility looks for information about Internet hosts. It gets this information from a set of widely distributed, interconnected servers. By default, it simply converts between host names and Internet addresses. With the -t or -a options, however, it can be used to find all of the information about this host that is maintained by the domain server.

The arguments can be either host names or host numbers. The program first attempts to interpret them as host numbers. If this fails, it will treat them as host names. A host number consists of first decimal numbers separated by dots, such as 172.31.255.253. A host name consists of names separated by dots, for example, topaz.anycollege.edu. Unless the name ends in a dot, the local domain is automatically added onto the end. Thus, an "Anycollege" user can say:"

host topaz

and it will actually look up "topaz.anycollege.edu". If this fails, the name is tried unchanged (in this case, "topaz"). This same convention is used for mail and other network utilities. The actual suffix to add onto the end is obtained by looking at the results of a hostname(1) call, and using everything starting at the first dot.

The first argument is the host name you want to look up. If this is a number, an inverse query is performed; the domain system looks in a separate set of databases used to convert numbers to names.

The second argument is optional. It allows you to specify a particular server to query. If you do not specify this argument, the default server (normally the local computer) is used.

If a name is specified, you might see output of three different kinds. Here is an example that shows all of them:

% host helios
helios.anycollege.edu is a nickname for ATHOS.ANYCOLLEGE.EDU
ATHOS.ANYCOLLEGE.EDU has address 172.16.5.46
ATHOS.ANYCOLLEGE.EDU has address 172.16.4.4
ATHOS.ANYCOLLEGE.EDU mail is handled by ARAMIS.ANYCOLLEGE.EDU

The user has typed the command host helios. The first line indicates that the name helios.anycollege.edu is actually a nickname. The official host name is ATHOS.ANYCOLLEGE.EDU. The next two lines show the address. If a system has more than one network interface, there will be a separate address for each. The last line indicates that ATHOS.ANYCOLLEGE.EDU does not receive its own mail. Mail for it is taken by ARAMIS.ANYCOLLEGE.EDU. There might be more than one such line because some systems have more than one other system that will handle mail for them. Technically, every system that can receive mail is supposed to have an entry of this kind. If the system receives its own mail, there should be an entry that mentions the system itself; for example:

ARAMIS.ANYCOLLEGE.EDU mail is handled by ARAMIS.ANYCOLLEGE.EDU 

Many systems that receive their own mail do not bother to mention that fact, however. If a system has "a mail is handled by" entry, but no address, this indicates that it is not really part of the Internet, but a system that is on the network will forward mail to it. Systems on Usenet, Bitnet, and several of other networks have entries of this kind.

OPTIONS

There are a number of options that can be used before the host name. Most of these options are meaningful only to those who must maintain the domain database.

-w
This causes host(1) to wait forever for a response. Normally, it will time out after approximately one minute.
-v
Use "verbose" format for printout. This is the official domain master file format, which is documented in the manual page for named(1). Without this option, output still follows this format in general terms, but some attempt is made to make it more intelligible to normal users. Without -v, any "a", "mx", and "cname" records are written out as "has address", "mail is handled by", and "is a nickname for" (respectively), and TTL and class fields are not shown.
-r
Turn off recursion in the request. This means that the name server will return only data that it has in its own database. It will not ask other servers for more information.
-d
Turn on debugging. Network transactions are shown in detail.
-c class
The class to look for non-Internet data.
-t querytype
Allows you to specify a particular querytype of information to be looked up. The arguments are defined in the manual page for named(1). Currently supported types include: a, ns, md, mf, cname, soa, mb, mg, mr, null, wks, ptr, hinfo, minfo, mx, uinfo, uid, gid, unspec. Additionally, the wildcard, which can be written as either Cm any or Cm *, can be used to specify any or all of the above types. Types must be given in lowercase. Note that the default is to look first for Cm a, and then Cm mx, unless the verbose option is turned on, in which case the default is only Cm a. The -t option is particularly useful for filtering information returned by host(1). For more information, see the explanation of the -l option later in this topic.
-a
All; this is equivalent to -v -t any.
-l
List a complete domain; for example:
host -l anycollege.edu

will give a listing of all hosts in the anycollege.edu domain. The -t option is used to filter what information is presented. The default is address information, which also include PTR and NS records. The command

host -l -v -t any anycollege.edu

will give a complete download of the zone data for anycollege.edu, in the official master file format. (However, the start of authority (SOA) record is listed twice, for arcane reasons.)

-l is implemented by doing a complete zone transfer and then filtering out the information the you have requested. This command should be used only if absolutely necessary.

CUSTOMIZING HOST NAME LOOKUP

Typically, if the name supplied by the user does not have any dots in it, a default domain is appended to the end. This domain can be defined in /etc/resolv.conf, but is normally derived by taking the local host name after its first dot. The user can override this and specify a different default domain using the environment variable LOCALDOMAIN. In addition, the user can supply his or her own abbreviations for host names. They should be in a file consisting of one line per abbreviation. Each line contains an abbreviation, a space, and then the full host name. The name file must be contained in the HOSTALIASES environment variable.

ENVIRONMENT VARIABLES

HOSTALIASES
Name of file containing (host alias, full hostname) pairs.

FILES

/etc/resolv.conf
See resolver(1).
$HOSTALIASES
Name of file containing host alias, full hostname) pairs.

BUGS

Unexpected effects can result if you type a name that is not part of the local domain. It is important to remember that the local domain name is added onto the end of every name, unless it ends in a dot. Only if this fails is the name used unchanged.

The -l option tries only the first name server listed for the domain that you have requested. If this server is unavailable, you might need to specify a server manually. For example, to get a listing of anycollege.edu, you could try:

host -t ns anycollege.edu
to get a list of all the name servers for anycollege.edu, and then try:
host -l anycollege.edu xxx
for all xxx on the list of name servers, until you find one that works.

SEE ALSO

resolver(5)