[SOLVED] Hotplug script to monitor an ethernet device is not executed

Hi all,

the port lan2 of my OpenWrt device (Linksys WRT1900ACS-V2) is cable connected with the lan port of an access point not running OpenWrt; as soon as I reboot the access point, OpenWrt system log says:

Fri Jan  3 19:00:42 2025 daemon.notice netifd: Network device 'lan2' link is down
Fri Jan  3 19:00:42 2025 kern.info kernel: [379772.003753] br-lan: port 2(lan2) entered disabled state
Fri Jan  3 19:00:42 2025 kern.info kernel: [379772.009383] mv88e6085 f1072004.mdio-mii:00 lan2: Link is Down
Fri Jan  3 19:00:47 2025 kern.info kernel: [379776.956196] mv88e6085 f1072004.mdio-mii:00 lan2: Link is Up - 1Gbps/Full - flow control rx/tx
Fri Jan  3 19:00:47 2025 kern.info kernel: [379776.956214] br-lan: port 2(lan2) entered blocking state
Fri Jan  3 19:00:47 2025 kern.info kernel: [379776.970206] br-lan: port 2(lan2) entered forwarding state
Fri Jan  3 19:00:47 2025 daemon.notice netifd: Network device 'lan2' link is up

Based on the above, on the OpenWrt device I created the /etc/hotplug.d/iface/90-my-action script containing:

#!/bin/sh
echo "Action: $ACTION" >> /tmp/debug-hotplug.log
echo "Interface: $INTERFACE" >> /tmp/debug-hotplug.log
echo "Device: $DEVICE" >> /tmp/debug-hotplug.log

Unfortunately, when I reboot the access point the /tmp/debug-hotplug.log file is not written, i.e. the script is not executed; I also get the same result if I move the script to /etc/hotplug.d/net/. Already surfed the forum, but not able to find anything useful: any hint?

(By the way, my ultimate goal is to take action as soon as the access point goes down/up).

Thanks in advance.

I believe the link state events are still being ignored or even filtered.

navigate in luci

network -> interfaces -> (edit the lan2/desired interface for the ethernet lan cable) -> advanced settings

and disable the force link option, save and apply.

keep the script in iface folder. reboot if needed.
check the log.

Thanks for the link, I missed this post; no idea how to write and use an ubus listener, I'll study the matter.

I already found this suggestion, but the Force link is only available with interface lan, not with device lan2. Moreover, the log shows me that the script is executed only once, when OpenWrt device reboots, and it does not run when lan2 goes down because the access point (e.g.) reboots, which is my goal...

then create an interface using add button. you can select the protocol unmanaged and device as the lan2 (/whichever ethernet is showing as) and in advanced setting disable the force link option, save and restart

1 Like

Saw what the other person said? Those events are intentionally filtered. So you would have to remove the filter. But it could have unintended side effects.

this is because at reboot all the interface is up and then no interface down is detected as force link is enabled

Thank you so much, it works as expected.

by the way, can you share your main purpose/action?

My goal is to send an email warning as soon as the network (lan2) speed between the OpenWrt device and the access point is less than 1 Gbps, and to perform the same action when the access point goes up/down.

I performed a quick test and your suggestion worked (problem solved), so my next step is writing the hotplug iface script to reach the goal.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.