You are not logged in.

#1 2021-03-01 06:54:32

bbus
Member
Registered: 2019-03-14
Posts: 49

[SOLVED] Clarify if dhcpcd@iface.service manages hotplug like ifplugd

The ifplugd for laptops has a note that

dhcpcd provides the same feature out of the box.

With the immediate description that ifplugd automatically configures/unconfigures for plugin/unplug events, the note makes it seem as if ifplugd is duplicative/unnecessary.

However, the dhcpcd wiki page says

...it does not support hot-plugging of a wired connection and will fail if the network cable is not connected.

My assumption is that, if I want hot-plugging, I need to use ifplugd@interface.service, and if I will only ever have a cable always plugged in, then I can reduce dependencies by only using dhcpcd@interface.service, in the case of, say, a desktop.

Please let me know if I am correct, or missing something. Thanks!

Last edited by bbus (2021-03-03 16:35:41)

Offline

#2 2021-03-01 08:04:00

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,584

Re: [SOLVED] Clarify if dhcpcd@iface.service manages hotplug like ifplugd

the wiki actshually wrote:

To avoid it, enable dhcpcd per interface it should bind to as described in #Running. The downside of the template unit is, however, that it does not support hot-plugging of a wired connection and will fail if the network cable is not connected.

The omitted context makes clear that this limitation only (and rather quite obviosly) applies for NIC specific services like dhcpcd@interface.service
The global dhcpcd.service however manages all and should™ be capable of juggling your NICs (if it doesn't: rant about it - rsmarples is active on this forum, he'll certainly like to hear ;-)

Offline

#3 2021-03-01 18:41:22

bbus
Member
Registered: 2019-03-14
Posts: 49

Re: [SOLVED] Clarify if dhcpcd@iface.service manages hotplug like ifplugd

So I need to clarify, I believe I am restricted to the NIC specific service file, because I am using iwd for my wireless control, and I am using iwd's own built-in DHCP client for that.

Maybe this question needs a new topic: If I enable a NIC specific ifplugd, (e.g. ifplugd@interface.service) will that start dhcpcd on a global scale, conflicting with my iwd configuration, or does it only start the NIC specific dhcpcd service?

Offline

#4 2021-03-01 20:46:09

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,584

Re: [SOLVED] Clarify if dhcpcd@iface.service manages hotplug like ifplugd

You can configure which devices to handle and there's also the interface daemon.

On top of that ifplugd will do nothing by itself, but run a script that you have to provide when the status changes.
You can eg. lookup /etc/ifplugd/netctl.action from the netctl package for a pattern. At this point you will decide whether and how to invoke a dhcp client like dhcpcd or dhclient.

Offline

#5 2021-03-01 22:28:01

bbus
Member
Registered: 2019-03-14
Posts: 49

Re: [SOLVED] Clarify if dhcpcd@iface.service manages hotplug like ifplugd

Got it, thank you for the help. I've configured /etc/ifplugd/ifplugd.conf such that INTERFACES="enp_my_wired_port_0 enp_my_wired_port_1" and I created a very basic ifplugd.action file. It seems to be working, but do you have any input on whether there are any blaring issues with it?

/etc/ifplugd/ifplugd.action

#!/bin/sh

case $2 in

  up)
    systemctl start dhcpcd@$1.service
    exit 0
  ;;
  down)
    systemctl stop dhcpcd@$1.service
    exit 0
  ;;
  *)
    echo "There has been an error"
  ;;
esac

exit 1

Last edited by bbus (2021-03-01 22:28:40)

Offline

#6 2021-03-02 08:40:11

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,584

Re: [SOLVED] Clarify if dhcpcd@iface.service manages hotplug like ifplugd

Do you need to deactivate the wifi connection as well?

An alternative approach could be to add an iwd hook to dhcpcd, https://wiki.archlinux.org/index.php/Dhcpcd#Hooks

Offline

#7 2021-03-03 16:33:55

bbus
Member
Registered: 2019-03-14
Posts: 49

Re: [SOLVED] Clarify if dhcpcd@iface.service manages hotplug like ifplugd

No, I don't think my use case needs to turn off my wifi connection. Maybe I will need to at some point if my ip tables get messed up. I could easily add "systemctl {stop/start} iwd.service" at the beginning and end, I suppose.

Ah, now with more context, that section makes more sense, thank you for bringing up dhcpcd hooks. I'll mark this as solved, and look into hooks when I get some more time. Thanks!

Offline

Board footer

Powered by FluxBB