TCP/IP and Data Communications Administration Guide

TCP/IP Configuration Files

Each machine on the network gets its TCP/IP configuration information from the following TCP/IP configuration files and network databases:

The Solaris installation program creates these files as part of the installation process. You can also edit the files manually, as explained in this section. The hosts and netmasks databases are two of the network databases read by the name services available on Solaris networks. "Network Databases and nsswitch.conf File" describes the concept of network databases in detail.

/etc/hostname.interface File

This file defines the network interfaces on the local host. At least one /etc/hostname.interface file should exist on the local machine. The Solaris installation program creates this file for you. In the file name, interface is replaced by the device name of the primary network interface.

The file contains only one entry: the host name or IP address associated with the network interface. For example, suppose smc0 is the primary network interface for a machine called ahaggar. Its /etc/hostname.interface file would have the name /etc/hostname.smc0; the file would contain the entry ahaggar.

For Multiple Network Interfaces

If a machine contains more than one network interface, you must create additional /etc/hostname.interface files for the additional network interfaces. You must create these files with a text editor; the Solaris installation program does not create them for you.

For example, consider the machine timbuktu shown in Figure 4-1. It has two network interfaces and functions as a router. The primary network interface le0 is connected to network 192.9.200. Its IP address is, and its host name is timbuktu. The Solaris installation program creates the file /etc/hostname.le0 for the primary network interface and enters the host name timbuktu in the file.

The second network interface is le1; it is connected to network 192.9.201. Although this interface is physically installed on machine timbuktu, it must have a separate IP address. Therefore, you have to manually create the /etc/hostname.le1 file for this interface; the entry in the file would be the router`s name, timbuktu-201.

/etc/nodename File

This file should contain one entry: the host name of the local machine. For example, on machine timbuktu, the file /etc/nodename would contain the entry timbuktu.

/etc/defaultdomain File

This file should contain one entry, the fully qualified domain name of the administrative domain to which the local host's network belongs. You can supply this name to the Solaris installation program or edit the file at a later date.

In Figure 4-1, the networks are part of the domain deserts.worldwide, which was classified as a .com domain. Therefore, /etc/defaultdomain should contain the entry For more information on network domains, refer to the Solaris Naming Administration Guide.

/etc/defaultrouter File

This file should contain an entry for each router directly connected to the network. The entry should be the name for the network interface that functions as a router between networks.

In Figure 4-1, the network interface le1 connects machine timbuktu with network 192.9.201. This interface has the unique name timbuktu-201. Thus, the machines on network 192.9.200 that are configured in local files mode have the name timbuktu-201 as the entry in /etc/defaultrouter.

hosts Database

The hosts database contains the IP addresses and host names of machines on your network. If you use the NIS, NIS+, or DNS name services, the hosts database is maintained in a database designated for host information. For example, on a network running NIS+, the hosts database is maintained in the host table.

If you use local files for name service, the hosts database is maintained in the /etc/inet/hosts file. This file contains the host names and IP addresses of the primary network interface, other network interfaces attached to the machine, and any other network addresses that the machine must know about.

Note -

For compatibility with BSD-based operating systems, the file /etc/hosts is a symbolic link to /etc/inet/hosts.

/etc/inet/hosts File Format

The /etc/inet/hosts file uses this basic syntax: (Refer to the hosts(4) man page for complete syntax information.)

IP-address hostname [nicknames] [#comment]

IP-address contains the IP address for each interface that the local host must know about.

hostname contains the host name assigned to the machine at setup, plus the host names assigned to additional network interfaces that the local host must know about.

[nickname] is an optional field containing a nickname for the host.

[# comment] is an optional field where you can include a comment.

Initial /etc/inet/hosts File

When you run the Solaris installation program on a machine, it sets up the initial /etc/inet/hosts file. This file contains the minimum entries that the local host requires: its loopback address, its IP address, and its host name.

For example, the Solaris installation program might create the following /etc/inet/hosts file for machine ahaggar shown in Figure 4-1:

Example 4-1 /etc/inet/hosts File for Machine ahaggar     localhost         loghost    #loopback address   ahaggar                      #host name

Loopback Address

In Example 4-1, the IP address is the loopback address, the reserved network interface used by the local machine to allow interprocess communication so that it sends 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 for the local host.

Host Name

The IP address and the name ahaggar are the address and host name of the local machine. They are assigned to the machine's primary network interface.

Multiple Network Interfaces

Some machines have more than one network interface, either because they are routers or multihomed hosts. Each additional network interface attached to the machine requires its own IP address and associated name. When you configure a router or multihomed host, you must manually add this information to the router's /etc/inet/hosts file. (See Chapter 5, Configuring Routers, for more information on setting up routers and multihomed hosts.)

Example 4-2 is the /etc/inet/hosts file for machine timbuktu shown in Figure 4-1.

Example 4-2 /etc/inet/hosts File for Machine timbuktu      localhost     loghost   timbuktu      #This is the local host name   timbuktu-201	#Interface to network 192.9.201

With these two interfaces, timbuktu connects networks 192.9.200 and 192.9.201 as a router.

How Name Services Affect the hosts Database

The NIS, NIS+, and DNS name services maintain host names and addresses on one or more servers. These servers maintain hosts databases containing information for every host and router (if applicable) on the servers' network. Refer to the Solaris Naming Administration Guide for more information about these services.

When Local Files Provide Name Service

On a network using local files for name service, machines running in local files mode consult their individual /etc/inet/hosts files for IP addresses and host names of other machines on the network. Therefore, their /etc/inet/hosts files must contain the:

Example 4-3 shows the /etc/inet/hosts file for machine tenere, a machine that runs in local files mode. Notice that the file contains the IP addresses and host names for every machine on the 192.9.200 network. It also contains the IP address and interface name timbuktu-201, which connects the 192.9.200 network to the 192.9.201 network.

A machine configured as a network client uses the local /etc/inet/hosts file for its loopback address and IP address.

Example 4-3 /etc/inet/hosts File for Machine Running in Local Files Mode


netmasks Database

You need to edit the netmasks database as part of network configuration only if you have set up subnetting on your network. The netmasks database consists of a list of networks and their associated subnet masks.

Note -

When you create subnets, each new network must be a separate physical network. You cannot apply subnetting to a single physical network.

What is Subnetting

Subnetting is a method for getting the most out of the limited 32-bit IP addressing space and reducing the size of the routing tables in a large internetwork. With any address class, subnetting provides a means of allocating a part of the host address space to network addresses, which lets you have more networks. The part of the host address space allocated to new network addresses is known as the subnet number.

In addition to making more efficient use of the IP address space, subnetting has several administrative benefits. Routing can become very complicated as the number of networks grows. A small organization, for example, might give each local network a class C number. As the organization grows, administering a number of different network numbers could become complicated. A better idea is to allocate a few class B network numbers to each major division in an organization. For instance, you could allocate one to Engineering, one to Operations, and so on. Then, you could divide each class B network into additional networks, using the additional network numbers gained by subnetting. This can also reduce the amount of routing information that must be communicated among routers.

Creating the Network Mask

As part of the subnetting process, you need to select a network-wide netmask. The netmask determines how many and which bits in the host address space represent the subnet number and how many and which represent the host number. Recall that the complete IP address consists of 32 bits. Depending on the address class, as many as 24 bits and as few as 8 bits can be available for representing the host address space. The netmask is specified in the netmasks database.

If you plan to use subnets, you must determine your netmask before you configure TCP/IP. You then need to carry out the procedures in "How to Add a Subnet to a Network". If you plan to install the operating system as part of network configuration, the Solaris installation program requests the netmask for your network.

As described in "Parts of the IP Address", 32-bit IP addresses consist of a network part and a host part. The 32 bits are divided into 4 bytes. Each byte is assigned either to the network number or the host number, depending on the network class.

For example, in a class B IP address, the 2 left-hand bytes are assigned to the network number, and the 2 right-hand bytes are assigned to the host number. In the class B IP address, you can assign the 2 right-hand bytes to hosts.

If you are going to implement subnetting, you need to use some of the bits in the bytes assigned to the host number to apply to subnet addresses. For example, a 16-bit host address space provides addressing for 65,534 hosts. If you apply the third byte to subnet addresses and the fourth to host addresses, you can address up to 254 networks, with up to 254 hosts on each.

The bits in the host address bytes that will be applied to subnet addresses and those applied to host addresses is determined by a subnet mask. Subnet masks are used to select bits from either byte for use as subnet addresses. Although netmask bits must be contiguous, they need not align on byte boundaries.

The netmask can be applied to an IP address using the bitwise logical AND operator. This operation selects out the network number and subnet number positions of the address.

It is easiest to explain netmasks in terms of their binary representation. You can use a calculator for binary-to-decimal conversion. The following examples show both the decimal and binary forms of the netmask.

If a netmask is applied to the IP address, the result is the IP address of & =

In binary form, the operation is:

10000001.10010000.00101001.01100101 (IP address)

ANDed with

11111111.11111111.11111111.00000000 (netmask)

Now the system looks for a network number of 129.144.41 instead of a network number of 129.144. If you have a network with the number 129.144.41, that is what the system looks for and finds. Since you can assign up to 254 values to the third byte of the IP address space, subnetting lets you create address space for 254 networks, where previously there was room for only one.

If you want to provide address space for only two additional networks, you could use a subnet mask of:

This netmask provides a result of:


This still leaves 14 bits available for host addresses. Since all 0s and 1s are reserved, at least two bits must be reserved for the host number.

Editing the /etc/inet/netmasks File

If your network runs NIS or NIS+, the servers for these name services maintain netmasks databases. For networks that use local files for name service, this information is maintained in the /etc/inet/netmasks file.

Note -

For compatibility with BSD-based operating systems, the file /etc/netmasks is a symbolic link to /etc/inet/netmasks.

Example 4-4 shows the /etc/inet/netmasks file for a class B network.

Example 4-4 /etc/inet/netmasks File for a Class B Network

## The netmasks file associates Internet Protocol (IP) address
 # masks with IP network numbers.
 # 	network-number	netmask
 # Both the network-number and the netmasks are specified in
 # "decimal dot" notation, e.g:

If the file does not exist, create it. Use the following syntax:

network-number	netmask-number

Refer to the netmasks(4) man page for complete details.

When creating netmask numbers, type the network number assigned by the InterNIC (not the subnet number) and netmask number in /etc/inet/netmasks. Each subnet mask should be on a separate line.

For example:

You can also type symbolic names for network numbers in the /etc/inet/hosts file. You can then use these network names instead of the network numbers as parameters to commands.

How to Add a Subnet to a Network

If you are changing from a network that does not use subnets to one that is subnetted, perform the following steps:

  1. Decide on the new subnet topology, including considerations for routers and locations of hosts on the subnets.

  2. Assign all subnet and host addresses.

  3. Modify the /etc/inet/netmasks file, if you are manually configuring TCP/IP, or supply the netmask to the Solaris installation program.

  4. Modify the /etc/inet/hosts files on all hosts to reflect the new host addresses.

  5. Reboot all machines.