The /etc/host.conf File

/etc/host.conf is a short, plain text file that specifies how host (i.e., computer) names on a network are resolved, i.e., matched with their corresponding IP addresses.

Each of the several possible options, represented by a configuration keyword, is written on a separate line in the file. The keywords are order, trim, multi, nospoof, spoof and reorder. Fields can be separated by white space, consisting of either one or more spaces or tabs. A hash character (#) introduces a comment that extends to the next line.

A typical /etc/host.conf file might resemble the following:

order hosts,bind
multi on
nospoof on

However, the file can have fewer or more lines. For example, some /etc/host.conf files contain only a single line containing the order option. Others might contain additional options and comments.

The order option specifies the order in which the resolving services are tried. Valid choices are bind for querying the BIND name server, hosts for lookups in the /etc/hosts file, and nis for NIS (network information service) lookups. Any or all of them may be specified. The order in which they appear on the line determines the order in which the respective services are tried by the resolver library. The above example specifies that /etc/hosts should be consulted first, and then BIND if necessary.

The multi option determines whether a host in the /etc/hosts file can have multiple IP addresses. It takes on or off as options. The default is off, as it may cause a substantial performance loss at sites with large hosts files.. This option has no effect on DNS or NIS queries.

The nospoof option is an instruction regarding IP spoofing, a type of security exploit, on the computer. Valid values are on and off.

The settings in /etc/host.conf can be overridden using any of several environment variables. Environmental variables are a class of variables that tell the shell how to behave as one works at the command line or in scripts.

Created October 8, 2005.
Copyright © 2005 The Linux Information Project. All Rights Reserved.