Questions about dhcpcd-hooks and IPv6 prefix delegation
Timo Sigurdsson
Sun Aug 05 14:30:42 2018
Hi,
as I recently moved from a cable based internet connection to a PPPoE connection, I also switched from ISC dhcp client to dhcpcd because ISC dhcp client won't operate on ppp interfaces.
The transition has been fairly easy, especially since dhcpcd makes prefix delegation quite simple compared to ISC dhcp (which will request a prefix but leave the delegation part up to you).
Nevertheless, I have a few questions about how to handle things cleanly and reliably in hook scripts:
1) I need to restart my firewall whenever prefix delegation is completed, i.e. after the last interface has been assigned a subnet of the new prefix. Currently, I do that when reason=DELEGATED6 and interface matches the last interfaces that I assign a delegated prefix to. But I noticed that the order in which the hooks are executed doesn't always seem to be the same. Imagine this configuration:
interface ppp0
ia_pd 1 enp2s0/1/64 enp3s0/2/64 enp4s0/3/64
Usually the hooks are called in the order enp2s0 enp3s0 and enp4s0. But for some reason, one time hooks on enp4s0 were executed before enp3s0 even though the order in interface_order was correct (for debugging purposes I logged the environment in my hook script upon each call and noticed that in the log that the order of execution was different one time).
Therefore, I'm looking for a way to reliably execute an action whenever the delegation is finished. Is there a good way to achieve this?
2) One of the few things that was nice about ISC's dhcp client was the fact that the environment of the hooks not only included the new delegated prefix, but it also included the previous prefix. That made it easier to distinguish the cases in which the prefix actually changed (and was not simply renewed). Since the actions I need to execute only need to be executed when a prefix actually changed, I'd like to know whether it's possible to get that information in the environment of the dhcpcd-hooks. I could of course write the prefix to a lease file and compare them upon each invocation, but I was wondering if there is a simpler way?
3) In addition, when the hooks are executed with the reason DELEGATED6, the environment only contains the subnet prefix which is assigned to one of the interfaces configured for delegation but not the full prefix which was obtained via DHCPv6. Is there a way to keep that in the environment for all delegated interfaces? Again, I can write it to a file and read it from there, but if there is a simpler way that doesn't require additional files, I'd prefer that.
FYI, I currently use dhcpcd 6.10.1 on Debian Stretch, but I'll package the latest release for myself in the next few days if it makes any difference.
Thanks and regards,
Timo
Archive administrator: postmaster@marples.name