OpenRC notebook roaming How-To

Abstract
This article shows how to set up OpenRC to act as a convenient, transparent and flexible networking client which supports roaming as an alternative to other solutions often used on notebooks.

Requirements
The currently stable version of these packages are all that is needed (no *kit software required)
 * OpenRC - management of services
 * have the netifrc USE flag enabled if you want the good old net.* style network management
 * enable the qt4 USE flag if you want to have a GUI for the Wi-FI client
 * - for hotplugging of ethernet interfaces
 * can be used as an alternative, but development has been discontinued
 * - for DHCP initiated connections (most Wi-Fi networks)
 * other compatible DHCP clients exist (dhclient provided by or udhcp provided by ), but dhcpcd is the recommended solution as it works well with often reconfigured wireless interfaces (so the wireless interface doesn't need hotplugging)
 * other compatible DHCP clients exist (dhclient provided by or udhcp provided by ), but dhcpcd is the recommended solution as it works well with often reconfigured wireless interfaces (so the wireless interface doesn't need hotplugging)

Configuration and setup
Before you start configuring the interfaces, make sure that they work (meaning you have the required drivers installed) and that you know their names. A convenient way is to make a Udev rule to give them human-readable names like ethernet0, wireless0.

OpenRC service management
For each interface an init script must be created for OpenRC to manage that interface by making a symlink to net.lo

where ${INTERFACE_NAME} is the name of the interface, e.g. eth0, wlan0, ethernet0, wireless0

If simple roaming is required, any network interface will satisfy the virtual net service. Therefore it is recommended to set rc_depend_strict="NO" in.

The services responsible for managing the interfaces must be added to one or more runlevel. This makes it possible to have network profiles by having most services in the default runlevel and then adding the interfaces to stacked runlevels and having different configuration files in for each runlevel as The options and syntax of  is described in the Gentoo Handbook which shows how to set up more complicated networks (this how-to assumes that all connections are initiated via DHCP)

Suspend to RAM example
With most services in the default runlevel and network services in a runlevel "network", which is stacked on top of the default runlevel, a PM hook for can be crated which transparently stops network services before suspending, thus preventing timeouts and other problems.

The hook must be executable

To boot into the network runlevel rather than the default one, must be changed as explained in the Handbook

The bootloader can also support multiple options for different setups

Exclusive network interface example
It may be desirable to have always only one networking interface configured. This can be done by the postup or postdown functions defined in

Network specific log-in procedure example
The postup or postup_${ESSID} (this function would be triggered only after successful connection to the given ${ESSID}) functions defined in can be used to submit data to e.g. a web log-in form

Wi-Fi management
A minimal is required to begin with. The permissions for the control interface should reflect who can configure the wireless interface. This minimal example assumes only users in the wheel group are allowed to configure the interface and that the configuration file can be updated by clients.

The use of the wpa_supplicant daemon on the interface may have to be enforced in. It is recommended to have dhcpcd watch the wireless interface (this is by default if no special networking setup is defined) and obtain and address when a carrier is acquired. Hotplugging via ifplugd is possible but isn't necessary as dhcpcd notices the change itself and ifplugd would slow down its reaction.

Clients
The wpa_supplicant daemon can be controlled via clients
 * wpa_cli - command-line client
 * wpa_gui - Qt4 based GUI client (only with the qt4 USE flag)
 * can be started in the system tray in the Xorg startup file .xinitrc

Ethernet management
OpenRC automatically hotplugs all interfaces if configured in /etc/rc.conf

so the respective services will be started if that interface becomes available and ifplugd will be automatically started for every ethernet interface to ensure that the device gets configured when a carrier is acquired (e.g. a cable is plugged in). Ifplugd will emit beeps on state change which can be disabled in