Previous | Next

Setting Up HOSTS Files

Microsoft TCP/IP can be configured to search the local host table file, HOSTS, for mappings of remote host names to IP addresses. The HOSTS file format is the same as the format for host tables in the version 4.3 Berkeley Software Distribution (BSD) UNIX /etc/hosts file. For example, the entry for a computer with an address of 192.102.73.6 and a host name of trey.research.com looks similar to this:

192.102.73.6        trey.research.com

Edit the sample HOSTS file that is created when you install TCP/IP to include remote host names and their IP addresses for each computer with which you will communicate. This sample file also explains the syntax of the HOSTS file.

Host names are used in virtually all TCP/IP environments. A host name always corresponds to an IP address that is stored in a HOSTS file or on a DNS server and is assigned by an administrator to identify a TCP/IP host or default gateway. A host name can be used in place of an IP address when using ping or other TCP/IP utilities.

Host names are not used in the Windows 98 network user interface, such as Network Neighborhood or Net.exe. The only time a host name is used to access a Windows-based computer is when ping or ftp or another TCP/IP utility is used. In this case, the host name and corresponding IP address must be stored in a HOSTS file.

The HOSTS file is a static file used to map host names to IP addresses. This file provides compatibility with the UNIX HOSTS file. The following describes HOSTS file entries:

For example, to connect to the UNIX host archive.research.com at the IP address 144.3.56.200, make two entries in the HOSTS file:

144.3.56.200     ARCHIVE.RESEARCH.COM
144.3.56.200     archive.research.com

This way, a user can connect to ARCHIVE using a utility, whether or not the CAPS LOCK is enabled.

A HOSTS file must reside on each system. By default, the host name localhost is an entry in the HOSTS file with the loopback address 127.0.0.1.

The HOSTS file is parsed whenever a host name is referenced. Names are read in a linear fashion. The most commonly used names should be near the beginning of the file. HOSTS file entries do not replace or interact with Windows-based NetBIOS computer names in any way.

The following shows the default HOSTS file provided with Windows 98.

# Copyright (c) 1994 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows 98
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the computer name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host
127.0.0.1     localhost