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 https://unix.stackexchange.com/a/309046/114497 .
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?
PS: I tried using 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.
ifplugd
). I have no idea if systemd listens to NETLINK events for network interfaces. – dirkt May 31 '19 at 17:25