This is Gentoo's testing wiki. It is a non-operational environment and its textual content is outdated.

Please visit our production wiki at https://wiki.gentoo.org

Network management using DHCPCD

From Gentoo Wiki (test)
Jump to:navigation Jump to:search

This article is based on a posting in the Gentoo Forums and explains how to use dhcpcd for complete network stack management.

Setup

Make sure dhcpcd is installed. Next, add it to the default runlevel and start the service:

root #rc-update add dhcpcd default
root #/etc/init.d/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.

Wireless

For wireless use wpa_supplicant. Either

To install the hook:

root #cp /usr/share/dhcpcd/hooks/10-wpa_supplicant /lib/dhcpcd/dhcpcd-hooks
root #/etc/init.d/dhcpcd restart
Important
Do not add wpa_supplicant to any runlevel if using the hook.

To use the wpa_supplicant approach, see the wpa_supplicant's Gentoo wiki page.

Testing

Stop dhcpcd and wpa_supplicant, then start dhcpcd with debugging enabled and in the foreground to see dhcpcd starting the connection.

root #/etc/init.d/dhcpcd stop
root #killall wpa_supplicant
root #dhcpcd -dB
dhcpcd[23772]: version 6.4.5 starting
dhcpcd[23772]: udev: starting
dhcpcd[23772]: dev: loaded udev
...
...

Static IP address

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 to /etc/dhcpcd.conf as described in Dhcpcd#Static_IP_addresses.

Migration from Gentoo net.* scripts

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 #/etc/init.d/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 useflag, re-emerge 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 --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

Manipulating network dependent services by dhcpcd is no longer supported since openrc-0.16.4.

Graphical User interface

A dhcpcd graphical user interface is provided by net-misc/dhcpcd-ui.

See also

External resources