I have a small usb-over-ethernet network of RPiZs connected to a single RPi4. I am accessing the zeros through an ethernet connection on the RPi4, so they need to send packets going to my laptop through the RPi4.
I created a hook at /lib/dhcpcd/dhcpcd-hooks/40-route
which is run by
/lib/dhcpcd/dhcpcd-run-hooks
.
It looks like this
# /lib/dhcpcd/dhcpcd-hooks/40-route
ip route replace 10.0/16 dev usb0
ip route replace 169.254/16 dev usb0 via 10.0.11.1 metric 101
If I run sudo sh /lib/dhcpcd/dhcpcd-run-hooks
, it makes the appropriate changes to my ip table.
However, I have to run it manually after every start up. Is there a way to get the hooks to run automatically? Or am I going about this completely wrong.
I feel this is on-topic for RPi SE because there is no other distribution that uses dhcpcd
as its default network manager.
date >> /tmp/run-hook.log; echo $reason >> /tmp/run-hook.log
. Note that if it is running, it is probably executed a bunch of times in close succession, since you don't appear to have checked the context via the environment at all./etc/dhcpcd.conf
might be useful too.$reason
,$interface
, andip route
before and after the changes. I found that the ip table changes remains stable with my changes in every round except the second to last where no reason or interface is listed, but in the next/final run the ip table starts missing my changes. Last round is IPV4LL for usb0. Then the changes are gone once it is started.