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.
Note: Valid host names or alias host names must contain at least one alphabetic character. If you choose to specify a host name or alias that begins with an x followed by any hexadecimal digit (0-f), the host name or alias must also contain at least one additional letter that cannot be expressed as a hexadecimal digit. The system interprets a leading x followed by a hexadecimal digit as the base 16 representation of an address, unless there is at least one character in the host name or alias that is not a hexadecimal digit. Thus, xdeer would be a valid host name, whereas xdee would not.
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.
Note: The local /etc/resolv.conf file defines where DOMAIN name servers are, and the name server file defines where Internet services are available. Although it is not necessary to define well-known hosts in the hosts file when using the DOMAIN protocol, it may be useful if they are not defined by your name server.
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.
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
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
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.
18.104.22.168 name1.xyz.aus.century.com name1 22.214.171.124 name2.xyz.aus.century.com name2 126.96.36.199 name3.xyz.aus.century.com name3
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.
This file is part of TCP/IP in Network Support Facilities in Base Operating System (BOS) Runtime.
The hostent command, setclock command.
The gethostbyaddr routine.
Domain Name Protocol (DOMAIN), Internet Protocol (IP), Naming for TCP/IP, Understanding the SMIT Interface for TCP/IP in AIX 5L Version 5.1 System Management Guide: Communications and Networks.