Sample Header Ad - 728x90

Execute a script on ethernet connection/disconnection with systemd

5 votes
2 answers
2482 views
I have an embedded device that will connect with systemd-networkd to a DHCP server if connected to the local network and will fall back to being a DHCP server if not. I didn't implement it yet but plan using the answer described here . This answer points to use a script that will be started on boot. I was wondering what if the user unplugs the network cable and connects it to a PC at runtime, he'd need to restart the board for the script to start. So the question is: is there a way to start a script when there's an interface change with systemd? I tried using [networkd-dispatcher](https://gitlab.com/craftyguy/networkd-dispatcher) without success. I tried restarting the systemd-networkd service, unplug the Ethernet cable, but the script I wrote located in /usr/lib/networkd-dispatcher is not executed.
Asked by David Bensoussan (151 rep)
May 31, 2019, 04:04 PM
Last activity: Jul 23, 2025, 04:03 PM