Online Book Reader

Home Category

UNIX System Administration Handbook - Evi Nemeth [187]

By Root 2656 0

hosts: files dns

Solaris configures the IP address of each network interface through a file called /etc/hostname.interface, where interface is the usual name of the interface (e.g., le0, smc0, or hme0). These files can contain either a hostname that appears in the hosts file or an IP address. Older versions of Solaris used hostnames, but newer ones use IP addresses. The value in a hostname.interface file is used as the address parameter to ifconfig, so it’s safest to use an address, even though the configuration filename implies that a hostname is expected. Any special ifconfig options can also be put in the hostname.interface file, but that is not commonly done. For interfaces with no corresponding hostname files, the startup scripts try to discover their IP addresses by using DHCP or RARP.20

As shipped, the Solaris startup files rely on using the ifconfig options netmask + and broadcast +; the pluses mean to look in /etc/netmasks for the netmask value and to figure out the broadcast address value from it. The /etc/netmasks21

file lists network numbers and their corresponding netmask values. Any network that is subnetted differently from its inherent network class (A, B, or C) must be represented in the file. Here is an example of a netmasks file:

# CS Department network masks database

# Network netmask

# ======= =======

#

128.138.0.0 255.255.255.192 # default for dept.

#

128.138.192.64 255.255.255.192 #drag

128.138.192.192 255.255.255.192 # csops

128.138.193.0 255.255.255.224 # bcrg

128.138.193.32 255.255.255.224 # database

128.138.198.0 255.255.255.0 # slip

...

The first line sets a default of /26 for the class B address 128.138.0.0, which is then overridden with specific masks that vary from the default. All networks are listed, even though many use the default value and could technically be left out. On the systems from which this example is taken, the netmasks file is centrally maintained and distributed to all hosts. No single host has interfaces on all these networks.

Interface configuration must be performed early in the boot process, before network information servers are started. Solaris redoes the ifconfigs several times after various services get started (on the theory that the extra services might provide more or better parameters to the ifconfig command).

To see the exact details, read the following startup scripts:

• /etc/init.d/rootusr

• /etc/init.d/inetinit

• /etc/init.d/sysid.net

• /etc/init.d/inetsvc

If the file /etc/defaultrouter exists, it is assumed to contain the identity (which again can be either a hostname or a numeric address) of the default gateway, and no further routing configuration is performed. As usual, a numeric address is preferable; using a name requires an /etc/hosts entry or a DNS server on the local network.

If no default router is specified, Solaris tries to run routed to build its routing tables. The number of network interfaces is counted, and if there is more than one interface or if the /etc/gateways file exists, routed is started in server mode and advertised by the router discovery daemon. If there is only one interface or if the /etc/notrouter file exists, routed is started in quiet mode. routed in any mode but quiet mode is evil—turn it off.22

Configuration examples for Solaris


Here are some examples of the commands needed to bring up a Solaris interface and add a route to a default gateway.

# ifconfig hme0 plumb

# ifconfig hme0 192.108.21.48 netmask 255.255.255.0 up

# route add default 192.108.21.254

The following examples show how to see the status of network interfaces and routing tables. Commands prefaced with sudo must be run as root. The final example shows a feature of the Solaris and FreeBSD route commands that is not present on our other architectures: the get argument shows the next hop to a particular destination. We have taken some liberties to make the examples fit on the page.

% ifconfig -a

lo0: flags=849 mtu 8232 inet 127.0.0.1

netmask ff000000

hme0:flags=863

Return Main Page Previous Page Next Page

®Online Book Reader