Network management using DHCPCD
Setup[edit | edit source]
Make sure dhcpcd is installed. Next, add it to the default runlevel and start the service:
root #
rc-update add dhcpcd default
root #
rc-service dhcpcd start
This setup deviates from the default networking instructions in the Gentoo Handbook. It has the advantage that it provides automatic switching between wired and wireless network interfaces.
wpa_supplicant[edit | edit source]
wpa_supplicant can be used for authentication of wireless and wired network interfaces. Create the configuration file if it does not exist.
/etc/wpa_supplicant/wpa_supplicant.conf
# Allow users in the 'wheel' group to control wpa_supplicant ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel # Make this file writable for wpa_gui / wpa_cli update_config=1
For authentication for the wired interface add the configuration file mentioned in Wpa_supplicant#Setup_wired_802.1X.
Emerge wpa_supplicant (Version >=2.6-r2 is needed in order to get the CONFIG_MATCH_IFACE option added in April 2017.)
root #
emerge --ask net-wireless/wpa_supplicant
Complete its conf.d file with the -M
option for the wireless network interface:
/etc/conf.d/wpa_supplicant
wpa_supplicant_args="-B -M -c/etc/wpa_supplicant/wpa_supplicant.conf"
In case authentication for the wired interface is needed this configuration file should look like
/etc/conf.d/wpa_supplicant
wpa_supplicant_args="-ieth0 -Dwired -c/etc/wpa_supplicant/wpa_supplicant_wired.conf -B -M -c/etc/wpa_supplicant/wpa_supplicant.conf"
With the configuration done, run it as a service:
root #
rc-update add wpa_supplicant default
root #
rc-service wpa_supplicant start
Wireless using net-wireless/iwd[edit | edit source]
See the iwd article.
Testing[edit | edit source]
Stop the dhcpcd service, then start dhcpcd with the -d (--debug) and -B (--nobackground) options enabled to see it starting the connection.
root #
rc-service etc/init.d/dhcpcd stop
root #
dhcpcd -dB
dhcpcd-6.11.3 starting dev: loaded udev eth0: executing `/lib/dhcpcd/dhcpcd-run-hooks' PREINIT eth0: executing `/lib/dhcpcd/dhcpcd-run-hooks' NOCARRIER wlan0: executing `/lib/dhcpcd/dhcpcd-run-hooks' PREINIT wlan0: executing `/lib/dhcpcd/dhcpcd-run-hooks' CARRIER DUID xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx wlan0: IAID XX:XX:XX:XX wlan0: delaying IPv6 router solicitation for 0.9 seconds wlan0: delaying IPv4 for 0.3 seconds eth0: waiting for carrier wlan0: reading lease `/var/lib/dhcpcd/dhcpcd-wlan0-.lease' wlan0: rebinding lease of 192.168.178.23 wlan0: sending REQUEST (xid 0x66820be2), next in 3.3 seconds wlan0: acknowledged 192.168.178.23 from 192.168.178.1 wlan0: leased 192.168.178.23 for 864000 seconds wlan0: renew in 432000 seconds, rebind in 756000 seconds wlan0: writing lease `/var/lib/dhcpcd/dhcpcd-wlan0-.lease' wlan0: IP address 192.168.178.23/24 already exists wlan0: changing route to 192.168.178.0/24 wlan0: changing default route via 192.168.178.1 wlan0: ARP announcing 192.168.178.23 (1 of 2), next in 2.0 seconds wlan0: executing `/lib/dhcpcd/dhcpcd-run-hooks' BOUND wlan0: soliciting an IPv6 router wlan0: sending Router Solicitation wlan0: ARP announcing 192.168.178.23 (2 of 2)
Static IP address[edit | edit source]
In case the network interface card should be configured with a static IP address, type it into the graphical user interface. Without the graphical user interface, entries can also be manually added (currently offline) to /etc/dhcpcd.conf as described in Dhcpcd#Static_IP_addresses.
Migration from Gentoo net.* scripts[edit | edit source]
When migrating from Gentoo's net.* scripts it is essential to remove the net.* scripts from the runlevels.
user $
rc-config list | grep 'wpa_supplicant\|dhcpcd\|net\.'
net.wlp8s0 default dhcpcd default
Any match starting with net.
must not have a runlevel assigned. In the above example, net.wlp8s0 needs to be removed.
root #
rc-update del net.wlp8s0
root #
rc-service net.wlp8s0 stop
Once the network setup works well, it is possible to completely remove the old Gentoo net.* scripts. To do so, disable the netifrc
USE flag, re-emerge sys-apps/openrc and finally unmerge net-misc/netifrc:
root #
echo 'sys-apps/openrc -netifrc' >> /etc/portage/package.use
root #
emerge --ask --newuse --oneshot sys-apps/openrc
root #
emerge --ask --verbose --depclean net-misc/netifrc
Also the old configuration files and symlinks can be removed:
root #
rm /etc/conf.d/net
root #
rm /etc/init.d/net.*
Network dependent services[edit | edit source]
Manipulating network dependent services by dhcpcd is no longer supported since openrc-0.16.4.
Graphical User interface[edit | edit source]
A dhcpcd graphical user interface is provided by net-misc/dhcpcd-ui.
See also[edit | edit source]
- Dhcpcd — a popular DHCP client capable of handling both IPv4 and IPv6 configuration.
- Dhcpcd-ui — a Qt and GTK monitor and configuration graphical user interface for dhcpcd.