host(1Mtcp)


host -- look up host names using domain server

Synopsis

host [ -l ] [ -v ] [ -w ] [ -r ] [ -d ] [ -c classtype ] [ -t querytype ] [ -a ] host
[ server ]

Description

host looks for information about Internet hosts. It gets this information from a set of interconnected servers that are spread across the country. 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 host and server 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 decimal numbers separated by dots (e.g. 128.6.4.194). A host name consists of names separated by dots (e.g. topaz.rutgers.edu.). Unless the name ends in a dot, the local domain is automatically tacked on the end. Thus a Rutgers user can say ``host topaz'', and it will actually look up ``topaz.rutgers.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 tack on the end is obtained by looking at the results of a gethostname(3bsd) call and using everything starting at the first dot. (See below for a description of how to customize the host name lookup.)

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

The server argument is optional. It allows you to specify a particular server to query. If you don't specify this argument, the default server (normally the local machine) is used.

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

   % host sun4 
   sun4.rutgers.edu is a nickname for ATHOS.RUTGERS.EDU 
   ATHOS.RUTGERS.EDU has address 128.6.5.46 
   ATHOS.RUTGERS.EDU has address 128.6.4.4 
   ATHOS.RUTGERS.EDU mail is handled by ARAMIS.RUTGERS.EDU 
The user has typed the command ``host sun4''. The first line indicates that the name ``sun4.rutgers.edu'' is actually a nickname. The official host name is ``ATHOS.RUTGERS.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.RUTGERS.EDU does not receive its own mail. Mail for it is taken by ARAMIS.RUTGERS.EDU. There may be more than one such line, since 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 ``AAA mail is handled by AAA''. Many systems that receive their own mail, however, do not bother to mention that fact. If a system has a ``mail is handled by'' entry, but no address entries, this indicates that the system is not really part of the Internet and that another system that is on the Internet will forward mail to it. Systems on Usenet, Bitnet, and a number of other networks have entries of this kind.

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

The option -w causes the querying host to wait forever for a response. Normally it will time out after around a minute.

The option -v causes printout to be in a ``verbose'' format. This is the official domain master file format, which is documented in the reference manual page named(1Mtcp). 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, ``a'', ``mx'', and ``cname'' records are written out as ``has address'', ``mail is handled by'', and ``is a nickname for'', and TTL and class fields are not shown.

The option -r causes recursion to be turned off in the request. This means that the name server will return only data it has in its own database. It will not ask other servers for more information.

The option -d turns on debugging. Network transactions are shown in detail.

The option -c allows you to specify a particular class of information to be looked up. Currently supported classes are:

in
specifies Internet addresses and other Internet information

hs
specifies MIT/Athena ``Hesiod'' information

any
specifies no restriction on information

The option -t allows you to specify a particular type of information to be looked up. host currently recognizes the following types: a, afsdb, cname, gid, hinfo, mb, md, mf, mg, minfo, mr, mx, ns, null, ptr, rp, soa, txt, uid, uinfo, wks, unspec, and the wildcard, which may be written as either ``any'' or ``*''. Types must be given in lower case. All of the above type names, except for unspec and any, are also names of types of resource records. For a description of the information retrieved by specifying a particular query type, see the description of the resource record type of the same name in the reference manual page named(1Mtcp). md and mf are not described in the named manual page because these are obsolete record types.

unspec is a non-standard query type and may not be supported by DNS servers. Note that the default is to look first for ``a'', and then ``mx'', except that if the verbose option is turned on, the default is only ``a''.

The option -a (for ``all'') is equivalent to ``-v -t any''.

The option -l causes a listing of a complete domain. For example,

host -l rutgers.edu

will give a listing of all hosts in the rutgers.edu domain. The default information in this listing will be address information, which also includes PTR and NS records. The -t option can be used in conjunction with -l to request additional or different information in the listing. The command

host -l -v -t any rutgers.edu

will give a complete download of the zone data for rutgers.edu, in the official master file format. (Note that the SOA record is listed twice, for arcane reasons.) NOTE: -l is implemented by doing a complete zone transfer and then filtering out the information you have asked for. This command should be used only if it is absolutely necessary.

Customizing host name lookup

In general, 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 hostname 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 own nicknames for host names. They should be in a file consisting of one line per nickname. Each line contains a nickname, a space, and then the full host name. This file must be pointed to by an environment variable HOSTALIASES, which is the name of the file.

Caveats

Unexpected effects can happen when you type a name that is not part of the local domain. Please always keep in mind the fact that the local domain name is tacked onto the end of every name, unless it ends in a dot. Only if this fails is the name used unchanged.

The -l option only tries the first name server listed for the domain that you have requested. If this server is inoperative, you may need to specify a server manually. For example: to get a listing of foo.edu, you could try host -t ns foo.edu to get a list of all the name servers for foo.edu, and then try host -l foo.edu xxx for all xxx on the list of name servers, until you find one that works.

References

named(1Mtcp), nslookup(1Mtcp)

RFC 1035


30 January 1998
© 1998 The Santa Cruz Operation, Inc. All rights reserved.