hosts File Format for TCP/IP
Defines the Internet Protocol (IP) name and address of the local host and specifies the names and addresses of remote hosts.
The /etc/hosts file contains the Internet Protocol (IP) host names and addresses for the local host and other hosts in the Internet network. This file is used to resolve a name into an address (that is, to translate a host name into its Internet address). When your system is using a name server, the file is accessed only if the name server cannot resolve the host name.
When the local host is using the DOMAIN protocol, the resolver routines query a remote DOMAIN name server before searching this file. In a flat network with no name server, the resolver routines search this file for host name and address data.
Entries in the hosts file have the following format:
In this entry, Address is an IP address specified in either dotted decimal or octal format, and HostName is the name of a host specified in either relative or absolute domain name format. If you specify the absolute domain name, the portion of the name preceding the first . (period) has a maximum length of 63 characters and cannot contain blanks. For both formats of the name, the total number of characters cannot exceed 255 characters, and each entry must be contained on one line. Multiple HostNames (or aliases) can be specified.
This file can contain two special case entries that define reserved (or well-known) host names. These host names are:
|timeserver||Identifies a remote time server host. This host name is used by the setclock command.|
|printserver||Identifies the default host for receiving print requests.|
In this hosts file entry, the Address parameter is an IP address specified in either dotted decimal or octal format, and each HostName parameter is a host name specified in either relative or absolute domain name format. These never have the full domain name listed; they are always listed as either printserver or timeserver.
Entries in this file can be made by using the System Management Interface Tool (SMIT) or the hostent command, or by creating and editing the file with an editor.
In these examples, the name of the local host is the first line in each hosts file. This is to help you identify the host whose file is being displayed. Your host does not have to be defined on the first line of your hosts file.
- The following sample entries might be contained in the hosts files for two different hosts on a network that is not running a
DOMAIN name server:
185.300.10.1 host1 185.300.10.2 host2 185.300.10.3 host3 185.300.10.4 host4 merlin 185.300.10.5 host5 arthur king 185.300.10.5 timeserver
In this sample network with no name server, the hosts file for each host must contain the Internet address and host name for each host on the network. Any host that is not listed cannot be accessed. The host at Internet address 185.300.10.4 in this example can be accessed by either name: host4 or merlin. The host at Internet address 185.300.10.5 can be accessed by any of the names host5, arthur, or king.
185.300.10.2 host2 185.300.10.1 host1 185.300.10.3 host3 185.300.10.4 host4 merlin 185.300.10.5 host5 arthur king
- Following is a sample entry in the hosts files for a different
host on a DOMAIN network, but the host is not the name server, and
the host is keeping some additional host names for a smaller network:
In this sample, host5 is not a name server, but is attached to a DOMAIN network. The hosts file for host5 contains address entries for all hosts in the smaller network, and the DOMAIN data files contain the DOMAIN database. The entries in thehost5 hosts file that begin with 128.114 indicate that host5 resolves names for hosts on the smaller network.
220.127.116.11 name1.xyz.aus.century.com name1 18.104.22.168 name2.xyz.aus.century.com name2 22.214.171.124 name3.xyz.aus.century.com name3