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
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
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
To determine whether another system can be contacted over the network, you use the ping command, as follows:
If host ultra10 is up, this message is displayed:
Ultra10 is alive
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
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:
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.
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.
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 126.96.36.199 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+.
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.
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.
::1 localhost 188.8.131.52 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.
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
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:
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.