Network management using DHCPCD

Abstract
Gentoo is about choice and also can be used with one of several network managers or even with none. This is about using OpenRC with DHCPCD as networkmanager. It is based on a posting in Gentoo Forums.

With DHCPCD it is possible to have a working network stack without resorting to Gentoo net.* scripts at all on simple configuration.


 * Only hardware interfaces are needed, i.e. no virtual interfaces;
 * IP addresses delivered through DHCP (eventually APIPA)

In such conditions all hardware interfaces can be configured, even the loopback interface, lo.

Basic configuration
Install dhcpcd

Remove all network scripts from all runlevels

Add dhcpcd to the default runlevel:

Wireless
When you need wireless support also install wpa_supplicant, Also note that older versions (< 6.4.4) of dhcpcd need wireless extensions compatibility in the kernel.

In case it's already installed and sits in a runlevel remove it from there.

Don't forget to set up and test the necessary wireless device drivers in your kernel. Check the configuration for the correct ctrl_interface.

There is no need for having wpa_supplicant in the runlevel as dhcpcd will detect the interface, whatever it is called and set its IP address automatically. Also note a nice thing Linux does when having wired and wireless interfaces together on the same network is that the one with the lowest metric takes precedence over existing connections.

Suppose for instance you have an ongoing transfer of a very large file over your wireless interface to an existing network mountpoint. Plug the cable and wait for dhcpcd to set the IP address of the ethernet interface and you'll see the network activity switch to the fastest interface. You don't even need to interrupt and restart the transfer. That feature comes handy when you cannot bond interfaces, especially with wireless.

Static IP address
In case the network interface card should be configured with a static IP address, put their data in the configuration file.

Cleanup
When the network setup is working well you might want to remove the old netifrc setup. So disable the netifrc useflag and reemerge OpenRC.

Now you can remove netifrc.

Also the old config files and symlinks can be removed

Network dependant services
Starting/stopping network dependant services is still in development. Services having "need net"

in their init.d scripts like fetchmail would then start after dhcpcd is started.

They will be stopped when dhcpcd turns inactive and will be restarted when dhcpcd is back.