ChorusOS 5.0 System Administrator's Guide

Chapter 10 Setting Up Ethernet

The ChorusOS Ethernet interface provides the standard solution for high-speed network connections with other systems. This chapter takes you through the process of setting up an Ethernet connection for a ChorusOS system. The four stages of setting up Ethernet are described sequentially:

  1. Hardware Configuration

  2. Interface Creation

  3. Device Creation

  4. Interface Configuration

If your system does not support Ethernet, or if you do not plan to use Ethernet with your system, you may skip this chapter.

Configuring Hardware

ChorusOS systems may support multiple Ethernet devices that all have their own Ethernet interface. See the appropriate guide in the ChorusOS 5.0 Target Platform Collection for the list of supported Ethernet devices for your particular target system hardware.

If you are unsure which Ethernet device your system uses, yet you are able to boot the system, you can use the dtree(1M) utility to display devices listed in the target system device tree:


$ rsh target dtree

A ChorusOS system often uses the Ethernet interface in conjunction with the Dynamic Host Configuration Protocol (DHCP) client or Reverse Address Resolution Protocol (RARP) to obtain an IP address at boot time. As the system runs, it uses the Address Resolution Protocol (ARP) to find the Ethernet addresses of other systems, based on their IP addresses.

Creating Interfaces

During system initialization, many network administration tasks are performed when the commands in sysadm.ini(4CC) are executed by the C_INIT system actor. Interface creation is no exception. In order to create the network interfaces that the system needs to communicate through Ethernet devices, you use the mkdev(1M) utility to create one interface for each Ethernet device on your target, and one loopback device for your target.. The command to create an Ethernet device thus takes the form:

mkdev ifeth unito [pathname]

where unit is the number that makes the interface unique and pathname is as shown in the output from the dtree(1M) utility. If you do not include pathname in the command, the ChorusOS system simply attaches the interface to the first free device it finds.


Note -

At this point, the network interface is bound to the Ethernet low-level driver, but Ethernet is not configured for use.



Example 10-1 Ethernet Interface Creation

The following example sysadm.ini fragment creates an interface for an Ethernet device and the loopback interface needed for IP communication.

#
# Set the file creation mask to 0 during system configuration
#
umask 0

#
# Create an Ethernet interface for the first available device
#
# Since no dtree *pathname* is provided, the system uses the first
# device it finds
#
mkdev ifeth 0

#
# Create a loopback interface
# 
# Note that the loopback device is not attached to a device in
# the dtree, so no *pathname* argument is provided here either
#
mkdev lo 0

Creating Devices

Ethernet connections only require corresponding devices if you configure Ethernet interfaces using the dhclient(1M) or rarp(1M) utility. Both of these utilities require a Berkeley Packet Filter (BPF).

It is also possible that your applications require a BPF device for raw access to network packets.

In order to create the BPF device, you can include commands of the following form in the sysadm.ini file that you build into the system image for your target:

# Create the BPF device
mkdev bpf unit
# Create the associated special file
mknod /dev/bpfunit c 23 unit

where unit is the number that makes the interface unique. Note that mknod(1M) is used to create special files. The c refers to the fact that BPF devices are character devices, and 23 is, by convention, the major number used for BPF devices.


Example 10-2 BPF Device Creation

The following example sysadm.ini fragment creates an interface for an Ethernet device and the loopback interface needed for IP communication. It then creates a BPF device needed by dhclient(1M) and rarp(1M).

umask 0
mkdev ifeth 0
mkdev lo 0

#
# Create a Berkeley Packet Filter device and special file
#
# The BPF device is used by either the rarp or dhclient command to
# configure the Ethernet interface
#
mkdev bpf 0
mknod /dev/bpf c 23 0

Configuring Interfaces

Once an interface has been created, you must configure it. Configuring the interface means providing an IP address, a subnet mask and a broadcast mask, and setting the status of the interface to up or down, depending on whether you want it to be operational.


Note -

This is true for IPv4. The new standard IPv6 creates its own address in "plug'nplay" style. See "IPv6 and the ChorusOS System".


Three utilities are provided to configure Ethernet interfaces on ChorusOS systems:

ifconfig

ifconfig(1M) can be used to configure as many Ethernet interfaces as necessary as long as the IP addresses for those interfaces are fixed.

rarp

rarp(1M) allows the ChorusOS system to configure an Ethernet interface with an IP address based on the Ethernet device address using the default subnet mask and broadcast address. This utility is specific to the ChorusOS product. It requires a BPF device on the ChorusOS system and a RARP server on the local network.

dhclient

dhclient(1M) allows the ChorusOS system to configure all parameters of the Ethernet interface, and also configure the routing tables. It requires a BPF device on the ChorusOS system and a DHCP server on the local network. It also requires that you build the dhclient process into the ChorusOS system image for your target (see "Embedding the dhclient process into the ChorusOS system image" for information about how to do this).

The three examples that follow demonstrate how to use the utilities described above.


Example 10-3 Ethernet Configuration with ifconfig

The following example sysadm.ini fragment creates an interface for an Ethernet device and the loopback interface needed for IP communication. It then configures the Ethernet interface.

#
# Set the file creation mask to 0 during system configuration
#
umask 0

#
# Create an Ethernet interface for the first available device
#
# Since no dtree *pathname* is provided, the system uses the first
# device it finds
#
mkdev ifeth 0

#
# Create a loopback interface
# 
# Note that the loopback device is not attached to a device in
# the dtree, so no *pathname* argument is provided here either
#
mkdev lo 0

#
# Set the file creation mask back to the default value
#
umask 22

#
# Configure the Ethernet interface using ifconfig
#
# Note that ADMIN_IFCONFIG must be set to true in order for this to
# work
#
ifconfig ifeth0 129.157.197.88 netmask 0xffffff00 
broadcast 129.157.197.255 up

#
# Configure the loopback interface as well
#
ifconfig lo0 127.0.0.1 up


Example 10-4 Ethernet Configuration with rarp

The following example sysadm.ini fragment creates an interface for an Ethernet device and the loopback interface needed for IP communication. It then creates a BPF device needed by rarp(1M) and configures the interface.

#
# Set the file creation mask to 0 during system configuration
#
umask 0

#
# Create an Ethernet interface for the first available device
#
# Since no dtree *pathname* is provided, the system uses the first
# device it finds
#
mkdev ifeth 0

#
# Create a loopback interface
# 
# Note that the loopback device is not attached to a device in
# the dtree, so no *pathname* argument is provided here either
#
mkdev lo 0

#
# Create a Berkeley Packet Filter device and special file
#
# The BPF device is used by either the rarp or dhclient command to
# configure the Ethernet interface
#
mkdev bpf 0
mknod /dev/bpf c 23 0

#
# Set the file creation mask back to the default value
#
umask 22

#
# Configure the Ethernet interface using rarp
#
# Note that BPF and ADMIN_RARP must be set to true in order for this
# to work
#
# rarp requires a BPF device
#
rarp ifeth0

#
# Configure the loopback interface as well
#
ifconfig lo0 127.0.0.1 up


Example 10-5 Ethernet Configuration with dhclient

The following example sysadm.ini fragment creates an interface for an Ethernet device and the loopback interface needed for IP communication. It then creates a BPF device needed by dhclient(1M) and configures the interface.

#
# Set the file creation mask to 0 during system configuration
#
umask 0

#
# Create an Ethernet interface for the first available device
#
# Since no dtree *pathname* is provided, the system uses the first
# device it finds
#
mkdev ifeth 0

#
# Create a loopback interface
# 
# Note that the loopback device is not attached to a device in
# the dtree, so no *pathname* argument is provided here either
#
mkdev lo 0

#
# Create a Berkeley Packet Filter device and special file
#
# The BPF device is used by either the rarp or dhclient command to
# configure the Ethernet interface
#
mkdev bpf 0
mknod /dev/bpf c 23 0

#
# Set the file creation mask back to the default value
#
umask 22

#
# Configure the Ethernet interface using dhclient
#
# Note that BPF must be set to true in order for this to work
#
# dhclient requires a BPF device
#
# dhclient also requires that the dhclient process be included in the 
# system image
# /image/sys_bank/dhclient ifeth0 &

#
# dhclient does not return until the server has responded
#
# Wait until the Ethernet interface is up to avoid confusing the system
#
ifwait ifeth0

#
# Configure the loopback interface as well
#
ifconfig lo0 127.0.0.1 up

Testing the Interface

Once you think the interface is configured properly, verify that the Ethernet connection is working:


$ rsh target ping host_IPv4_address
host_IP_address is alive

or


$ rsh target ping6 host_IPv6_address
host_IP_address is alive

Another way of verifying that the Ethernet connection is working is to use ifconfig. See "ifconfig".