What's new

WANFailover Dual WAN Failover Script

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Hello. Is there no way to make email notification settings from amtm and through it, and not through Ai Protection? Ai Protection notifications have never worked for me, even on a router with clean firmware.
Hmm I’d have to look at how amtm configures email for alerts.
 
Hmm I’d have to look at how amtm configures email for alerts.
You can configure it through the web interface of the "common" script, you can use the graphical interface of AMTM. But I do not know how it works, but it works flawlessly.
 

Attachments

  • email_1.png
    email_1.png
    66.5 KB · Views: 64
You can configure it through the web interface of the "common" script, you can use the graphical interface of AMTM. But I do not know how it works, but it works flawlessly.
Yea I meant on the backend how it is configured.
 
v1.5.4-beta Release:
Manually upgrade to this beta by running the following command" ***Allow for cronjob to relaunch the script***
Code:
/usr/sbin/curl -s "https://raw.githubusercontent.com/Ranger802004/asusmerlin/main/wan-failover_v1.5.4-beta.sh" -o "/jffs/scripts/wan-failover.sh" && chmod 755 /jffs/scripts/wan-failover.sh && sh /jffs/scripts/wan-failover.sh kill

To revert back to Production Release:
Code:
/jffs/scripts/wan-failover.sh update

***To configure new boot delay timer, run config option to specify the Boot Delay Timer in Seconds, if a Boot Delay Timer is not configured, the script will ignore this function and continue***

*** This version changes how IP Rules / Routes are created, you can delete the old static routes created by the script under Routing Table Main or reboot the router to remove them***


Release Notes:
v1.5.4-beta
- Added delay in WAN Status for when NVRAM is inaccessible.
- Added support for Load Balance Mode
- Changed from using NVRAM Variables: wan0_ifname & wan1_ifname to using NVRAM Variables: wan0_gw_ifname & wan1_gw_ifname.
- Improved DNS Settings detection during Switch WAN function.
- Improved Switch WAN Logic to verify NVRAM Variables: wan_gateway, wan_gw_ifname, and wan_ipaddr are properly updated.
- Added warning message when attempting to execute Run or Manual Mode if the script is already running.
- Support for ASUS Merlin Firmware 386.7
- Added Boot Delay Timer
- Target IP Routes are now created using IP Rules from Local Router to Routing Table 100 (WAN0) and Routing Table 200 (WAN1) so client devices on the network do not use the created routes.
- Moved Email Variables from Global Variables so Email Configuration is checked every time a switch occurs instead of when script restarts.
- Email Notification will not be sent if System Uptime is less than 60 seconds + Boot Delay Timer if configured. This is created because the firmware will start up with WAN1 as Active Connection and switch to WAN0 with the script.
- Added integration for amtm email notifications, if amtm is properly configured, it will be used for Email Notifications, otherwise it will attempt to use AIProtection Alerts.
 
You can configure it through the web interface of the "common" script, you can use the graphical interface of AMTM. But I do not know how it works, but it works flawlessly.
Ask and you shall receive, let me know how this works out.

 
Ask and you shall receive, let me know how this works out.

Everything worked fine when modeling the WAN0 failure situation, notifications came. Great job guys, you are the best!
 
v1.5.4 has been published as a production release. Refer to original post for information and details on how to update to this version. Thank you to all of those who contributed to testing and data collection for resolving issues as well as adding features!
 
Running v1.5.4 since last 24hrs no weird freezes , or any other freaky behavior yet .

Running flawlessly .

Looks like the old issue was cause of a bad flash , hopefully , cross my heart the factory reset fixed it .

Running multiple scripts and all is well, touch wood @Ranger802004
 
Running v1.5.4 since last 24hrs no weird freezes , or any other freaky behavior yet .

Running flawlessly .

Looks like the old issue was cause of a bad flash , hopefully , cross my heart the factory reset fixed it .

Running multiple scripts and all is well, touch wood @Ranger802004
Excellent news!
 
Updated to v1.5.4 yesterday - added my manual route to the Cablemodem - then rebooted, tested failover/fallback and all is working well - thank you :)
You could have your firewall-start script or wan-event do this for you so you don't have to manually add it every time? Use the below example, replace <Insert Cable Modem IP> with the IP you need in Line 1 and Line 2.

Code:
if [ -z "$(ip route list <Insert Cable Modem IP>)" ] >/dev/null;then
  ip route add <Insert Cable Modem IP> dev $(nvram get wan1_gw_ifname)
fi
 
Hello. Installed AdGuard Home (ad blocker) via AMTM WAN Failover is triggered when WAN0 fails, but it cannot return to WAN0 indefinitely, while WAN0 is already in working condition. Only stopping the AdGuard Home service helps.

Jul 1 13:10:07 router wan-failover.sh: WAN Status - wan1 has 0% packet loss
Jul 1 13:10:07 router wan-failover.sh: WAN0 Active - Verifying WAN0
Jul 1 13:10:07 router wan-failover.sh: WAN Switch - Switching wan0 to Primary WAN
Jul 1 13:10:07 router wan-failover.sh: WAN Switch - WAN IP Address: 178.249.55.33
Jul 1 13:10:07 router wan-failover.sh: WAN Switch - WAN Gateway: 178.249.55.254
Jul 1 13:10:07 router wan-failover.sh: WAN Switch - DNS1 Server: 8.8.8.8
 
You could have your firewall-start script or wan-event do this for you so you don't have to manually add it every time? Use the below example, replace <Insert Cable Modem IP> with the IP you need in Line 1 and Line 2.

Code:
if [ -z "$(ip route list <Insert Cable Modem IP>)" ] >/dev/null;then
  ip route add <Insert Cable Modem IP> dev $(nvram get wan1_gw_ifname)
fi
Thank you - this is a much cleaner way of doing it and not having to update that often
 
Hello. Installed AdGuard Home (ad blocker) via AMTM WAN Failover is triggered when WAN0 fails, but it cannot return to WAN0 indefinitely, while WAN0 is already in working condition. Only stopping the AdGuard Home service helps.

Jul 1 13:10:07 router wan-failover.sh: WAN Status - wan1 has 0% packet loss
Jul 1 13:10:07 router wan-failover.sh: WAN0 Active - Verifying WAN0
Jul 1 13:10:07 router wan-failover.sh: WAN Switch - Switching wan0 to Primary WAN
Jul 1 13:10:07 router wan-failover.sh: WAN Switch - WAN IP Address: 178.249.55.33
Jul 1 13:10:07 router wan-failover.sh: WAN Switch - WAN Gateway: 178.249.55.254
Jul 1 13:10:07 router wan-failover.sh: WAN Switch - DNS1 Server: 8.8.8.8

Do you have more logs to work with for this? I’m not sure what is going on here, I need more data.
 
Do you have more logs to work with for this? I’m not sure what is going on here, I need more data.
wan-failover.sh - Monitor Mode
Jul 1 17:33:00 router wan-failover.sh: WAN Status - Adding default route for wan0 Routing Table via 178.249.55.254 dev eth0
Jul 1 17:33:00 router wan-failover.sh: WAN Status - Added default route for wan0 Routing Table via 178.249.55.254 dev eth0
Jul 1 17:33:00 router wan-failover.sh: WAN Status - Adding IP Rule for 119.29.29.29
Jul 1 17:33:00 router wan-failover.sh: WAN Status - Added IP Rule for 119.29.29.29
Jul 1 17:33:04 router wan-failover.sh: WAN Status - wan0 has 0% packet loss
Jul 1 17:33:04 router wan-failover.sh: WAN Status - wan1 enabled
Jul 1 17:33:04 router wan-failover.sh: WAN Status - Adding default route for wan1 Routing Table via 192.168.199.1 dev eth2
Jul 1 17:33:04 router wan-failover.sh: WAN Status - Added default route for wan1 Routing Table via 192.168.199.1 dev eth2
Jul 1 17:33:04 router wan-failover.sh: WAN Status - Adding IP Rule for 119.28.28.28
Jul 1 17:33:04 router wan-failover.sh: WAN Status - Added IP Rule for 119.28.28.28
Jul 1 17:33:08 router wan-failover.sh: WAN Status - wan1 has 0% packet loss
Jul 1 17:33:08 router wan-failover.sh: WAN0 Active - Verifying WAN0
Jul 1 17:33:08 router wan-failover.sh: WAN0 Failover Monitor - Monitoring wan0 via 119.29.29.29 for Failure
Jul 1 17:35:03 router wan-failover.sh: WAN0 Failover Monitor - Packet Loss Detected - WAN0 Packet Loss: 20%
Jul 1 17:35:08 router wan-failover.sh: WAN0 Failover Monitor - Failure Detected - WAN0 Packet Loss: 100%
Jul 1 17:35:08 router wan-failover.sh: WAN Switch - Switching wan1 to Primary WAN
Jul 1 17:35:09 router wan-failover.sh: WAN Switch - WAN IP Address: 192.168.199.100
Jul 1 17:35:09 router wan-failover.sh: WAN Switch - WAN Gateway: 192.168.199.1
Jul 1 17:35:09 router wan-failover.sh: WAN Switch - WAN Interface: eth2
Jul 1 17:35:09 router wan-failover.sh: WAN Switch - WAN Interface: eth2
Jul 1 17:35:09 router wan-failover.sh: WAN Switch - DNS1 Server: 8.8.8.8
Jul 1 17:36:00 router wan-failover.sh: WAN Status - wan0 enabled
Jul 1 17:36:00 router wan-failover.sh: WAN Status - Restarting WAN0: eth0
Jul 1 17:37:36 router wan-failover.sh: WAN Status - Restarted WAN0: eth0
Jul 1 17:38:00 router wan-failover.sh: WAN Status - wan0 enabled
Jul 1 17:38:00 router wan-failover.sh: WAN Status - Adding default route for wan0 Routing Table via 178.249.55.254 dev eth0
Jul 1 17:38:00 router wan-failover.sh: WAN Status - Added default route for wan0 Routing Table via 178.249.55.254 dev eth0
Jul 1 17:38:00 router wan-failover.sh: WAN Status - Adding IP Rule for 119.29.29.29
Jul 1 17:38:00 router wan-failover.sh: WAN Status - Added IP Rule for 119.29.29.29
Jul 1 17:38:04 router wan-failover.sh: WAN Status - wan0 has 0% packet loss
Jul 1 17:38:04 router wan-failover.sh: WAN Status - wan1 enabled
Jul 1 17:38:04 router wan-failover.sh: WAN Status - Adding default route for wan1 Routing Table via 192.168.199.1 dev eth2
Jul 1 17:38:04 router wan-failover.sh: WAN Status - Added default route for wan1 Routing Table via 192.168.199.1 dev eth2
Jul 1 17:38:04 router wan-failover.sh: WAN Status - Adding IP Rule for 119.28.28.28
Jul 1 17:38:04 router wan-failover.sh: WAN Status - Added IP Rule for 119.28.28.28
Jul 1 17:38:08 router wan-failover.sh: WAN Status - wan1 has 0% packet loss
Jul 1 17:38:08 router wan-failover.sh: WAN0 Active - Verifying WAN0
Jul 1 17:38:08 router wan-failover.sh: WAN Switch - Switching wan0 to Primary WAN
Jul 1 17:38:08 router wan-failover.sh: WAN Switch - WAN IP Address: 178.249.55.33
Jul 1 17:38:08 router wan-failover.sh: WAN Switch - WAN Gateway: 178.249.55.254
Jul 1 17:38:08 router wan-failover.sh: WAN Switch - WAN Interface: eth0
Jul 1 17:38:08 router wan-failover.sh: WAN Switch - WAN Interface: eth0
Jul 1 17:38:08 router wan-failover.sh: WAN Switch - DNS1 Server: 8.8.8.8
Jul 1 17:39:00 router wan-failover.sh: WAN Status - wan0 enabled
Jul 1 17:39:00 router wan-failover.sh: WAN Status - Adding default route for wan0 Routing Table via 178.249.55.254 dev eth0
Jul 1 17:39:00 router wan-failover.sh: WAN Status - Added default route for wan0 Routing Table via 178.249.55.254 dev eth0
Jul 1 17:39:00 router wan-failover.sh: WAN Status - Adding IP Rule for 119.29.29.29
Jul 1 17:39:00 router wan-failover.sh: WAN Status - Added IP Rule for 119.29.29.29
Jul 1 17:39:04 router wan-failover.sh: WAN Status - wan0 has 0% packet loss
Jul 1 17:39:04 router wan-failover.sh: WAN Status - wan1 enabled
Jul 1 17:39:04 router wan-failover.sh: WAN Status - Adding default route for wan1 Routing Table via 192.168.199.1 dev eth2
Jul 1 17:39:04 router wan-failover.sh: WAN Status - Added default route for wan1 Routing Table via 192.168.199.1 dev eth2
Jul 1 17:39:04 router wan-failover.sh: WAN Status - Adding IP Rule for 119.28.28.28
Jul 1 17:39:04 router wan-failover.sh: WAN Status - Added IP Rule for 119.28.28.28
Jul 1 17:39:09 router wan-failover.sh: WAN Status - wan1 has 20% packet loss
Jul 1 17:39:09 router wan-failover.sh: WAN0 Active - Verifying WAN0
Jul 1 17:39:09 router wan-failover.sh: WAN Switch - Switching wan0 to Primary WAN
Jul 1 17:39:09 router wan-failover.sh: WAN Switch - DNS1 Server: 8.8.8.8
Jul 1 17:40:00 router wan-failover.sh: WAN Status - wan0 enabled
Jul 1 17:40:00 router wan-failover.sh: WAN Status - Adding default route for wan0 Routing Table via 178.249.55.254 dev eth0
Jul 1 17:40:00 router wan-failover.sh: WAN Status - Added default route for wan0 Routing Table via 178.249.55.254 dev eth0
Jul 1 17:40:00 router wan-failover.sh: WAN Status - Adding IP Rule for 119.29.29.29
Jul 1 17:40:00 router wan-failover.sh: WAN Status - Added IP Rule for 119.29.29.29
Jul 1 17:40:04 router wan-failover.sh: WAN Status - wan0 has 0% packet loss
Jul 1 17:40:04 router wan-failover.sh: WAN Status - wan1 enabled
Jul 1 17:40:04 router wan-failover.sh: WAN Status - Adding default route for wan1 Routing Table via 192.168.199.1 dev eth2
Jul 1 17:40:04 router wan-failover.sh: WAN Status - Added default route for wan1 Routing Table via 192.168.199.1 dev eth2
Jul 1 17:40:04 router wan-failover.sh: WAN Status - Adding IP Rule for 119.28.28.28
Jul 1 17:40:04 router wan-failover.sh: WAN Status - Added IP Rule for 119.28.28.28
Jul 1 17:40:08 router wan-failover.sh: WAN Status - wan1 has 0% packet loss
Jul 1 17:40:09 router wan-failover.sh: WAN0 Active - Verifying WAN0
Jul 1 17:40:09 router wan-failover.sh: WAN Switch - Switching wan0 to Primary WAN
Jul 1 17:40:09 router wan-failover.sh: WAN Switch - DNS1 Server: 8.8.8.8
Jul 1 17:41:00 router wan-failover.sh: WAN Status - wan0 enabled
Jul 1 17:41:00 router wan-failover.sh: WAN Status - Adding default route for wan0 Routing Table via 178.249.55.254 dev eth0
Jul 1 17:41:00 router wan-failover.sh: WAN Status - Added default route for wan0 Routing Table via 178.249.55.254 dev eth0
Jul 1 17:41:00 router wan-failover.sh: WAN Status - Adding IP Rule for 119.29.29.29
Jul 1 17:41:00 router wan-failover.sh: WAN Status - Added IP Rule for 119.29.29.29
Jul 1 17:41:04 router wan-failover.sh: WAN Status - wan0 has 0% packet loss
Jul 1 17:41:04 router wan-failover.sh: WAN Status - wan1 enabled
Jul 1 17:41:04 router wan-failover.sh: WAN Status - Adding default route for wan1 Routing Table via 192.168.199.1 dev eth2
Jul 1 17:41:04 router wan-failover.sh: WAN Status - Added default route for wan1 Routing Table via 192.168.199.1 dev eth2
Jul 1 17:41:04 router wan-failover.sh: WAN Status - Adding IP Rule for 119.28.28.28
Jul 1 17:41:04 router wan-failover.sh: WAN Status - Added IP Rule for 119.28.28.28
Jul 1 17:41:08 router wan-failover.sh: WAN Status - wan1 has 0% packet loss
Jul 1 17:41:08 router wan-failover.sh: WAN0 Active - Verifying WAN0
Jul 1 17:41:08 router wan-failover.sh: WAN Switch - Switching wan0 to Primary WAN
Jul 1 17:41:09 router wan-failover.sh: WAN Switch - DNS1 Server: 8.8.8.8
 
Full log. Line 3254 stopping AdGuardHome
It looks like AdGuard may be deleting the IP Rules or routes needed for failover to work? I’m not familiar with the tool but I do see where every time it goes back to WAN Status check it is having to recreate them and starts working again.
 
It looks like AdGuard may be deleting the IP Rules or routes needed for failover to work? I’m not familiar with the tool but I do see where every time it goes back to WAN Status check it is having to recreate them and starts working again.
I don't insist, maybe there will be time to see how the AdGuardHome scripts work and there will be an idea how to make Dual WAN Failover work together. I am grateful in advance. LINK
 
Last edited:
I don't insist, maybe there will be time to see how the AdGuardHome scripts work and there will be an idea how to make Dual WAN Failover work together. I am grateful in advance. LINK
When I get some free time, I will see how it interacts and see what I can come up with.
 

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top