I have Debian 10 running on a small SBC (industrialized Raspberry Pi like form factor). I have some python programs running that make use of inotify capabilities. I want to detect when the network status changes so I can toggle a light. Should I look around for some files in something like /sys/class/net/eth1 and watch for a change with notify? and compute a status from whats in that directory somehow? Or is there a better way to do this that doesn't involve polling?

I was trying to infer this from my mqtt client connection status, but that's not responsive enough and at times is ambiguous anyway.

Is there perhaps some hook that systemd/networkd would provide to make this possible?


1 Answer 1


Just add post-up and post-down stanzas:

iface eth0 inet .....
    post-up   /path/to/my/super/up-script.sh
    post-down /path/to/my/super/down-script.sh
  • So I could set some state with these scripts in my ramfs, and then watch that file for changes in my python program using notify? I need to mux this info with the mqtt status to manipulate my light, otherwise, i guess i could just do simple gpio for my light right there in the scripts Mar 31, 2021 at 18:20
  • I'm using files in systemd/network to configure my adapter. I guess I need to find what the syntax is for putting these hooks in there. Mar 31, 2021 at 19:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .