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

  • 1
    this is a Linux question, not a Raspberry Pi question ... it belongs at unix.stackexchange.com/questions
    – jsotola
    Aug 6 at 17:44
  • Unfortunately, your question has been closed to new answers. I've submitted a request that it be re-opened, but that's probably a long-shot. Before I invest more time, can you tell me if you've read this?
    – Seamus
    2 days ago
  • I've re-opened this, but you might want to demonstrate more definitely that it does not run, eg., by shimming in something like 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.
    – goldilocks
    2 days ago
  • The meatier bits of /etc/dhcpcd.conf might be useful too.
    – goldilocks
    2 days ago


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.