Network management using DHCPCD

Dynamic Host Configuration Protocol Client Daemon (DHCPCD) is a popular DHCP client for Gentoo Linux users. DHCPCD offers a large feature set and easily integrates into OpenRC. This article is about using OpenRC with DHCPCD as network manager. It is based on a posting in Gentoo Forums.

Installation
Install dhcpcd, add it to the default runlevel and start it:

All its configuration goes into but for most installations nothing needs to be done there, presumed that most computers nowadays are behind a router or access point providing dhcp. Though man 5 dhcpcd.conf will be helpful in case of advanced configuration demand.

Wireless
Dhcpcd comes with a built-in hook for wpa_supplicant, so it's best choice to install this for wireless. The necessary wireless device drivers in your kernel need to be installed. Also note that the older versions (≤2.0-r2) of wpa_supplicant need "env wpa_supplicant_driver=nl80211" in.

Create the configuration file, put the content shown below, install wpa_supplicant and restart dhcpcd:

For any questions or problems with wpa_supplicant see the references.

Static IP address
In case the network interface card should be configured with a static IP address, type it into the Graphical User interface or manually add it to the configuration file as shown for the following example.

Migration from Gentoo net.* scripts
In case of migration from Gentoo net.* scripts it's essential to remove wpa_supplicant and the net.* scripts from the runlevels.

Any lines starting with "net." must not have a runlevel assigned. In this example, it's net.wlp8s0 to be removed.

Once the network setup works well you might want to completely remove the old Gentoo net.* scripts setup. So disable the netifrc useflag, re-emerge OpenRC without and unmerge netifrc:

Also the old config files and symlinks can be removed