Gestión de red mediante DHCPCD

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page Network management using DHCPCD and the translation is 37% complete.
Outdated translations are marked like this.

Este artículo está basado en un hilo de los foros de Gentoo y explica como utilizar dhcpcd para la gestión completa de la pila de red.

Of course, it's possible to use dhcpcd together with net.* scripts. In fact, if dhcpcd is installed, it's used as the default DHCP client if config_eth0="dhcp" is set in /etc/conf.d/net. This article is specifically about using dhcpcd standalone.

Configuración

Asegúrese de que se ha instalado dhcpcd. A continuación añádalo al nivel de ejecución por defecto y arranque el servicio:

If using OpenRC, do:

root #rc-update add dhcpcd default
root #/etc/init.d/dhcpcd start

Or, if using systemd:

root #systemctl enable dhcpcd
root #systemctl start dhcpcd

Esta configuración difiere de las instrucciones por defecto de la configuración de la red en el manual de Gentoo. Tiene la ventaja de que ofrece conmutación automática entre interfaces de red cableadas e inalámbricas.

Wireless

wpa_supplicant

wpa_supplicant can be used for authentication of wireless and wired network interfaces. Create the configuration file if it does not exist:

ARCHIVO /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.

First follow the setup guide for dhcpcd.

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

Using OpenRC

Complete its conf.d file with the -M option for the wireless network interface:

ARCHIVO /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:

ARCHIVO /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

Using Systemd

Systemd allows a simpler per-device setup without needing to create the above conf.d files. As explained under wpa_supplicant item in the Native services section, a service symlink such as wpa_supplicant@wlan0.service looks for a separate configuration file to manage the device wlan0 in this case.

To configure a specific device this way, first copy or rename the /etc/wpa_supplicant/wpa_supplicant.conf file as /etc/wpa_supplicant/wpa_supplicant-DEVNAME.conf where DEVNAME should be the name of the device, such as wlan0.

Then, navigate to /etc/systemd/system/multi-user.target.wants and create the symlink:

root #ln -s /lib/systemd/system/wpa_supplicant@.service wpa_supplicant@DEVNAME.service

where DEVNAME is same device name as in the conf file above.

Importante
Note the @ signs on both arguments in the symlink step.

Test the system:

root #systemctl daemon-reload
root #systemctl start wpa_supplicant@DEVNAME
root #systemctl status wpa_supplicant@DEVNAME

Using net-wireless/iwd

See the iwd article.

Pruebas

Pare dhcpcd y wpa_supplicant y a continuación arranque dhcpcd con la depuración activada y en primer plano para comprobar cómo dhcpcd arranca la conexión.

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
...
...

Dirección IP estática

En el caso en que la tarjeta de interfaz de red se deba configurar con una dirección IP estática, tecléela en la interfaz gráfica de usuario. Sino se dispone de la interfaz gráfica de usuario, se pueden añadir entradas de forma manual a /etc/dhcpcd.conf tal y como se describe en direcciones IP estáticas.

Migración desde los guiones net.* de Gentoo

Cuando se migra desde los guiones net.* de Gentoo es muy importante eliminar los guiones net.* de los niveles de ejecución.

user $rc-config list | grep 'wpa_supplicant\|dhcpcd\|net.'
  net.wlp8s0                default
  dhcpcd                    default

No se debe asignar ningún nivel de ejecución a cualquier coincidencia que comience por net.. En el ejemplo de arriba se necesita eliminar net.wlp8s0.

root #rc-update del net.wlp8s0
root #/etc/init.d/net.wlp8s0 stop

Una vez se compruebe el correcto funcionamiento de la configuración de la red, es posible eliminar completamente los antiguos guiones Gentoo net.*. Para hacerlo, deshabilitar el ajuste USE netifrc, vuelva a hacer emerge de OpenRC y finalmente desinstale 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

También se pueden eliminar los ficheros y enlaces simbólicos de la configuración anterior:

root #rm /etc/conf.d/net
root #rm /etc/init.d/net.*

Servicios dependientes de la red

No se permite la manipulación de servicios dependientes de la red con dhcpcd a partir de la versión 0.16.4 de openrc.

Interfaz Gráfica de Usuario

Se ofrece una interfaz gráfica de usuario para dhcpcd en el paquete net-misc/dhcpcd-ui.

Véase también

Recursos externos