The hosts database contains the IPv4 addresses and host names of machines on your network. If you use the NIS, NIS+, or DNS name services (or LDAP as a name service), the hosts database is maintained in a database that is designated for host information. For example, on a network that runs NIS+, the hosts database is maintained in the host table.
If you use local files for the name service, the hosts database is maintained in the /etc/inet/hosts file. This file contains the host names and IPv4 addresses of the primary network interface, other network interfaces that are attached to the machine, and any other network addresses that the machine must check for.
The /etc/inet/hosts file uses the basic syntax that follows. Refer to the hosts(4) man page for complete syntax information.
IPv4-address hostname [nicknames] [#comment]
IPv4-address contains the IPv4 address for each interface that the local host must recognize.
hostname contains the host name that is assigned to the machine at setup, plus the host names that are assigned to additional network interfaces that the local host must recognize.
[nickname] is an optional field that contains a nickname for the host.
[# comment] is an optional field for a comment.
When you run the Solaris installation program on a machine, the program configures the initial /etc/inet/hosts file. This file contains the minimum entries that the local host requires. The entries include the loopback address, the host IPv4 address, and the host name.
For example, the Solaris installation program might create the following /etc/inet/hosts file for machine tenere shown in Figure 4–1:
127.0.0.1 localhost loghost #loopback address 220.127.116.11 tenere #host name
In Example 5–1, the IPv4 address 127.0.0.1 is the loopback address. The loopback address is the reserved network interface that is used by the local machine to allow interprocess communication. This enables the host to send packets to itself. The ifconfig command uses the loopback address for configuration and testing, as explained in ifconfig Command. Every machine on a TCP/IP network must use the IP address 127.0.0.1 for the local host.
Some machines have more than one network interface, because they are either routers or multihomed hosts. Each additional network interface that is attached to the machine requires its own IPv4 address and associated name. When you configure a router or multihomed host, you must add this information manually to the router's /etc/inet/hosts file. See Configuring Routers for more information on configuring routers and multihomed hosts.
127.0.0.1 localhost loghost 18.104.22.168 timbuktu #This is the local host name 22.214.171.124 timbuktu-201 #Interface to network 192.9.201
The NIS, NIS+, and DNS name services (or LDAP as a name service) maintain host names and addresses on one or more servers. These servers maintain hosts databases that contain information for every host and router (if applicable) on the servers' network. Refer to System Administration Guide: Naming and Directory Services (DNS, NIS, and LDAP) and System Administration Guide: Naming and Directory Services (FNS and NIS+) for more information about these services.
On a network that uses local files for name service, machines that run in local files mode consult their individual /etc/inet/hosts files for IPv4 addresses and host names of other machines on the network. Therefore, these machine's /etc/inet/hosts files must contain the following:
IPv4 address and host name of the local machine (primary network interface)
IPv4 address and host name of additional network interfaces that are attached to this machine, if applicable
IPv4 addresses and host names of all hosts on the local network
IPv4 addresses and host names of any routers that this machine must know about, if applicable
IPv4 address of any machine your machine wants to refer to by its host name
The figure below shows the /etc/inet/hosts file for machine tenere. This machine runs in local files mode. Notice that the file contains the IPv4 addresses and host names for every machine on the 192.9.200 network. The file also contains the IPv4 address and interface name timbuktu-201. This interface connects the 192.9.200 network to the 192.9.201 network.