Run custom script on connection failover

Hi All

i have RUT9xx router, and have 2 WAN providers (converted lan3 to wan2 to use 2 providers)

how to run custom script when wan connection became unreliable?


You can just create a failover rule instead of creating a custom script. After converting LAN3 to WAN2, you can go to Network → Failover → Then assign which interface you will prioritize the most. Here are some links that help me configure the same.

Hope this helps!

thnx, but i need also to switch on relay GPIO, when primary connection sets unreliable and switch relay off when primary WAN returns to online state.

I already converted LAN3 to WAN2, all works ok,
So, main question - how to run script on event “came offline/came online of WAN connection”

main problem that remote installation with RUT9xx router will be unacessible when main WAN goes offline, so it need to automatically switch power on and toggling other GPIO for run spare device that suppluying WAN2 link when WAN1 came offline
and switch power off after some timeout when main WAN returns online.

so best solution will be run some script on events.


Custom commands triggered by mwan3 failover can be placed in the /etc/mwan3.user script. There are 4 possible actions:

  • ifup - interface is marked as up in the Network → WAN;

  • ifdown - interface is marked as down in the Network → WAN;

  • connected - the interface is able to reach a specified host in the mwan3 configuration;

  • disconnected - the specified host is not reachable via this interface (even though it can still be considered as up by netifd);

Hope this helps!

This topic was automatically closed after 15 days. New replies are no longer allowed.