Hi. I am looking for a solution to trigger a script when the default route changes/main interface is down/restored.
So, I have 2 network interfaces:
- ethernet enp2s0 with default metric 1
- 4g mobile enx0 with default metric 2
When Ethernet goes down, the metric changes and vice versa. I am getting in systems notifications something like this:
systemd-resolved[628]: enp2s0: Bus client set default route setting: no
systemd-resolved[628]: enx0: Bus client set default route setting: yes
When the Ethernet connection is restored, it changes back:
systemd-resolved[628]: enp2s0: Bus client set default route setting: yes
systemd-resolved[628]: enx0: Bus client set default route setting: no
I have Ubuntu SystemD, and I have self-written script to send any notifications via one of public messengers, so in my case there will be 2 scenarios:
- send_messenger.sh "me" "the traffic is routed through 4g connection from now, please, be patient" when Ethernet is down and the modem enabled
- send_messenger.sh "me" "ethernet is back, the normal bandwidth is available" when Ethernet goes back.
What may be a systemd unit service which may trigger that script when the default route changes? Or one of the network interfaces is disconnected?
[link] [comments]
SOCIAL SHARE CARD GENERATOR