I use systemd-networkd to configure my network with and basically just have:

cat /etc/systemd/network/eth1-dhcp.network


But now ,I need to make some changes to my system (a raspberry pi like device) when the network goes down. I have tried a few things.

-1 I notice that I can watch the /sys/class/net/eth1/carrier for but it only changes when the physical network connection changes.

-2 When I run journalctl -fu systemd-networkd I can watch systemd-networkd react to network connectivity changes.

-3 I have tried adding scripts like the following:

cat /etc/network/if-down.d/downTrigger.sh
/usr/bin/echo `/usr/bin/date` > /run/justDownTriggered

ls -l /etc/network/if-down.d/downTrigger.sh
-rwxr-xr-x 1 root root 65 Apr  2 22:03 /etc/network/if-down.d/downTrigger.sh

Said script runs manually just fine, but does not run when I disconnect the network. I tried a variant in if-post-down.d as well. Are these triggers separate from systemd-networkd perhaps?

Bottom line, I want to hook up something so I can write a file in run or send a signal or whatever when the eth1 network goes down per my current systemd-networkd configuration at the top. Is it possible? The command I actually want to run when this goes down is:

`systemctl restart my_other_service`

when the network goes down. If there was a way to just put that dependency in the my_other_serivce.service file, I'd be all for that. The trigger is that it should restart (not stop) when the network goes down.

(I am running on Debian 10)

  • See https://github.com/waltinator/net-o-matic it watches for "network down" and does a user-specified thing.
    – waltinator
    Apr 3 at 13:15

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.