Run dhcp on all ethernet devices

My laptop doesn't have a built-in ethernet controller (WiFi only). I want all Ethernet devices to be dhcp-ed automatically, as soon as they appear (USB tethering phone, USB-to-ethernet adaptor). But I don't want to mess up the configuration for my WiFi card.

Lightly modified /usr/lib/systemd/system/dhcpcd.service (Arch Linux)

Description=dhcpcd on all en* interfaces

# Only allow ethernet devices, ignore unrenamed devices as udev
# will (try to) rename them whilst dhcpcd is fiddling with them
ExecStart=/usr/bin/dhcpcd -q -b --allowinterfaces 'en*' --denyinterfaces 'eth*'
ExecStop=/usr/bin/dhcpcd -x


Put this in /etc/systemd/system/dhcpcd-all-en.service and run

systemctl daemon-reload
systemctl enable --now dhcpcd-all-en


↩ Home