Previous Page
Next Page

Network Interfaces

A Sun system normally contains at least one network interface, to allow it to participate in a network environment. When you add a network interface to a system, a number of files need to be configured in order to create the connection between the hardware and the software address assigned to the interface. The following sections describe how to monitor, control, and configure an IPv4 network interface.

Controlling and Monitoring an IPv4 Network Interface

Objective:

  • Control and monitor network interfaces including MAC addresses, IP addresses, network packets, and configure the IPv4 interfaces at boot time.

As root, you can use the ifconfig -a command to display both the system's IP and MAC addresses, as in this example:

ifconfig -a
lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
     inet 127.0.0.1 netmask ff000000
hme0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
      inet 192.168.1.106 netmask ffffff00 broadcast 192.168.1.255
      ether 8:0:20:a2:63:82

You can also retrieve the MAC address from a system by using the banner command at the OpenBoot prompt, as described in Chapter 3, "Perform System Boot and Shutdown Procedures."

Note

Displaying a MAC Address If you enter the ifconfig -a command as a nonprivileged user, then only the IP address information is displayed. In order to display the MAC address as well as the IP address, the root user must enter ifconfig -a command.


You can mark an Ethernet interface as up or down by using the ifconfig command. Marking an interface as up allows it to communicate on the network. For example, to mark the hme0 interface as down, you use the following command:

ifconfig hme0 down
ifconfig -a
lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
     inet 127.0.0.1 netmask ff000000
hme0: flags=1000842<BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
      inet 192.168.1.106 netmask ffffff00 broadcast 192.168.1.255
      ether 8:0:20:a2:63:82

Notice that the up flags are no longer present for the hme0 interface and also that the value of flags has changed to 1000842.

To mark the interface as up, you use the following command:

ifconfig hme0 up
ifconfig -a
lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
     inet 127.0.0.1 netmask ff000000
hme0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
      index 2 inet 192.168.1.106 netmask ffffff00 broadcast 192.168.1.255
      ether 8:0:20:a2:63:82

When the network interface is marked as up, the interface is ready to communicate with other systems on the network.

To determine whether another system can be contacted over the network, you use the ping command, as follows:

ping ultra10

If host ultra10 is up, this message is displayed:

Ultra10 is alive

Note

Names to Addresses The ultra10 is alive command assumes that the host ultra10 can be resolved either through an entry in the /etc/hosts file or by using DNS. If you do not know the hostname, you can use the ping command with the IP address instead of the hostname.


The message indicates that ultra10 responded to the request and can be contacted. However, if ultra10 is down or cannot receive the request, you receive the following response:

no answer from ultra10

In order for a ping request to be successful, the following conditions must be met:

  • The interface must be plumbed This is automatically carried out at boot time by the script /lib/svc/method/net-physical, as discussed in the section "Configuring an IPv4 Network Interface," later in this chapter.

  • The interface must be configured An address must be assigned to a network interface; this is carried out initially when you install the Solaris operating environment. Configuring the interface is discussed in the section "Configuring an IPv4 Network Interface," later in this chapter.

  • The interface must be up The network interface can communicate only when it is marked as up. This is done via the ifconfig command.

  • The interface must be physically connected The network interface must be connected to the network, using the appropriate cable.

  • The interface must have valid routes configured The routing provides the directions to the destination computer. This is an advanced networking topic that is not covered on the exam, but it is included here for completeness. A separate Solaris certification exam, "Solaris Network Administrator," deals with routing in detail.

Configuring an IPv4 Network Interface

When you install the Solaris operating environment, you configure a network interface as part of the installation program. You can configure additional interfaces at system boot time, or you can modify the original interface by having an understanding of only four files:

  • /lib/svc/method/net-physical

  • /etc/hostname.<interface>

  • /etc/inet/hosts

  • /etc/inet/ipnodes

Each of these is discussed in the following sections.

The /lib/svc/method/net-physical File

This script uses the ifconfig utility to configure each network interface that has an IP address assigned to it, by searching for files named hostname.<interface> in the /etc directory. An example of such a file is /etc/hostname.hme0, which refers to the configuration file for the first hme network interface (interface numbering starts with 0, not 1hence hme1 would be the second hme interface on the system).

For each hostname.<interface> file, the script runs the ifconfig command with the plumb option, which effectively installs the interface and enables the kernel to communicate with the named network interface.

Note

A New Startup Script The file /lib/svc/method/net-physical is new in the Solaris 10 operating environment. Those who are familiar with releases prior to Solaris 10 will recognize that this script carries out the same functions as the file /etc/rcS.d/S30network.sh in previous releases, but it is now part of the Service Management Facility (SMF).


The /etc/hostname.<interface> File

The files> files> /etc/hostname.<interface> 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 filename, <interface> is replaced by the device name of the primary network interface.

This file contains only one entry: the hostname or IP address associated with the network interface. For example, suppose hme0 is the primary network interface for a machine called system1. The file would be called /etc/hostname.hme0, and the file would contain the entry system1 files> files>.

The /etc/inet/hosts File

The hosts database contains details of the machines on your network. This file contains the hostnames and IP addresses of the primary network interface and any other network addresses the machine must know about. You can use the /etc/inet/hosts file with other hosts databases, such as DNS, NIS, and NIS+. When a user enters a command such as ping xena, the system needs to know how to get to the host named xena. The /etc/inet/hosts file provides a cross-reference to look up and find xena's network IP address. For compatibility with Berkeley Software Distribution (BSD)-based Unix operating systems, the file /etc/hosts is a symbolic link to /etc/inet/hosts.

Each line in the /etc/inet/hosts file uses the following format:

<address> <hostname> <nickname> [# comment]

Each field in this syntax is described in Table 8.5.

Table 8.5. The /etc/inet/hosts File Format

Field

Description

<address>

The IPv4 address for each interface the local host must know about.

<hostname>

The hostname assigned to the machine at setup and the hostnames assigned to additional network interfaces that the local host must know about.

<nickname>

An optional field that contains a nickname or an alias for the host. More than one nickname can exist.

[# comment]

An optional field in which you can include a comment.


When you run the Solaris installation program on a system, 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 hostname.

For example, the Solaris installation program might create the following entries in the /etc/inet/hosts file for a system called xena:

127.0.0.1        localhost             #loopback address
192.9.200.3      xena              loghost    #hostname

In the /etc/inet/hosts file for the machine xena, the IP address 127.0.0.1 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 operating system, through the ifconfig command, uses the loopback address for configuration and testing. Every machine on a TCP/IP network must have an entry for the localhost and must use the IP address 127.0.0.1.

The /etc/inet/ipnodes File

The ipnodes database contains details of the machines on your network. This file, like the /etc/inet/hosts file, contains the hostnames and IP addresses of the primary network interface and any other network addresses the machine must know about, but, unlike the /etc/inet/hosts file, the file can also contain IPv6 addresses. You can use the /etc/inet/ipnodes file with other hosts databases, such as DNS, NIS, and NIS+.

Exam Alert

No Compatibility /etc linkYou should note that there is no /etc/ipnodes link to /etc/inet/ipnodes. This is a very common mistake to make in the exam when presented with /etc/ipnodes as an option.


Each line in the /etc/inet/ipnodes file uses the following format:

<address> <hostname> <nickname> [# comment]

Each field in this syntax is described in Table 8.6.

Table 8.6. The /etc/inet/ipnodes File Format

Field

Description

<address>

The IPv4 or IPv6 address for each host or interface the local host must know about.

<hostname>

The hostname assigned to the machine at setup and the hostnames assigned to additional network interfaces that the local host must know about.

<nickname>

An optional field that contains a nickname or an alias for the host. More than one nickname can exist.

[# comment]

An optional field in which you can include a comment.


When you run the Solaris installation program on a system, it sets up the initial /etc/inet/ipnodes file. This file contains the minimum entries that the local host requires: its loopback address, its IPv4 or IPv6 address, and its hostname.

For example, the Solaris installation program creates the following entries in the /etc/inet/ipnodes file for the system called xena used in the previous section:

::1       localhost
192.9.200.3     xena     loghost

The following step by step demonstrates how to configure a network interface from the command line. In this exercise, we'll configure the primary network interface (hme0) to achieve connectivity with other systems on the network. The hostname will be set to Achilles, with an IP Address of 192.168.0.111, and a network mask of 255.255.255.0, and the interface will be made operational as well.

Step By Step 8.1: Configuring an IPv4 Network Interface

1.
Display the current network interface configuration using the ifconfig command and make sure the interface is down as follows:

# ifconfig hme0 down
#ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL>
 mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000
hme0: flags=1000842<BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500
 index 2
        inet 192.168.7.1 netmask ffffff00 broadcast 192.168.7.255
        ether 8:0:20:1e:86:90

2.
Edit the files /etc/inet/hosts and /etc/inet/ipnodes and add the following entry:

192.168.0.111   achilles

3.
Edit the file /etc/hostname.hme0 to contain the following entry:

achilles

4.
Edit the file /etc/inet/netmasks and add the following entry:

192.168.0.0     255.255.255.0

5.
The pre-configuration of the interface is now complete. We can now use the ifconfig command to initialize the interface and make it operational, as follows:

# ifconfig hme0 achilles netmask + broadcast + up

6.
Verify that the interface is now operational and correctly configured, using the ifconfig -a command, as follows:

# ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL>
 mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000
hme0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500
 index 2
        inet 192.168.0.111 netmask ffffff00 broadcast 192.168.0.255
        ether 8:0:20:1e:86:90


Exam Alert

Use the Plus (+)Using the + option to the ifconfig command causes a lookup in the /etc/inet/netmasks file to determine the correct values, based on the network mask value that has been inserted for the relevant network. You must make sure the /etc/inet/netmasks file is accurate for this to work correctly. You can always specify the full values to the ifconfig command, but it requires that the broadcast address is calculated manually, which can be difficult when subnetworks are used.


Changing the System Hostname

There are two methods available for changing the system hostname: The first is to edit the necessary files manually and reboot the system, as described here.

The system's hostname is contained within four files on a Solaris system. It is necessary to modify all these files in order to successfully change the hostname of a system manually. These files need to be changed:

  • /etc/nodename This file contains the local source for a system name. In other words, it contains the hostname of the system. The only information contained within this file is the name of the system (for example, ultra10). This is the location where the system hostname is set. You can change the hostname by running the command uname -S and supplying a new hostname, but if you do so, the change does not persist across reboots. The command uname -n, which prints the node name of the system, looks in this file for the information.

  • /etc/hostname.<interface> This file defines the network interfaces on the local host and is discussed earlier in this chapter, in the section "The /etc/hostname.<interface> File."

  • /etc/inet/hosts The hosts file contains details of the machines on your network and is discussed earlier in this chapter, in the section "The /etc/inet/hosts File."

  • /etc/inet/ipnodes This file contains details of the machines on your network and includes both IPv4 and IPv6 addresses. It is discussed in the previous section of this chapter, "The /etc/inet/ipnodes File."

Having changed the contents of the files listed above, the system needs to be rebooted to implement the new hostname.

The second method for changing the hostname is to use the sys-unconfig command. The result of running this command is the removal of the system identification details, similar to when you initiate a Solaris 10 installation.

When the command completes, the system automatically shuts down. To complete the process, boot the system. You will be presented with a number of configuration questions, such as hostname, IP address, subnet mask, default router, time zone, naming service configuration, and the root passwordall very similar to when you perform an initial installation of the Solaris 10 Operating Environment.


Previous Page
Next Page