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!

This is wan-event. I did setup alerts. Ill try disabling those.
#!/bin/bash

sh /jffs/scripts/wan-failover.sh cron # Wan-Failover

EDIT: I was just messing with this again, did a stupid user error made the wantargets the same, thinking its just pinging to verify connection. But it makes the static route.. duh. Took me a few to figure out what the hell i did. But after some thought I think i need to figure out a different way of testing.
When starlink boots up, and gives the router a ip, then after it connects to a satellite dhcp sends out another ip... How ive been testing is rebooting the starlink router, that might be screwing this up. I mentioned last saturday it had switched many times fine during some storms.. That was just lack
of signal/internet, not rebooting the router.

jsut did ip link set dev eth0 down... wait until it switches.. ip link set dev eth0 up.. Switches back.....

Additional edit: so after doing this many times, it worked flawless. So that screwup in my testing was probably all of that issue. But the script does fix the hot-standby.
So on my end, Just doing a warm reboot of starlink takes about 1-2mins, but a cold reboot like a power outage can take up to 15mins.. So I need to make wan-failover.sh wait awhile on router boot to start.
Do you think it's worth doing a check for the IP / Gateway changing for a WAN Interface? Typically if that happens it leaves state 2 and bounces out of the failover monitor to check WAN Status again.

Also I finished writing the readme after you restarted using the script where I called this out explicitly here. lol
During installation or reconfiguration, the following settings are configured:
- WAN0 Target: This is the target IP address for WAN0, the script will monitor this IP via ICMP Echo Requests “ping” over the WAN0 interface. Verify the target IP address is a valid server for ICMP Echo Requests prior to installation or configuration. It is recommended to use different Target IP Addresses for each WAN interface. Example: 8.8.8.8
- WAN1 Target: This is the target IP address for WAN1, the script will monitor this IP via ICMP Echo Requests “ping” over the WAN1 interface. Verify the target IP address is a valid server for ICMP Echo Requests prior to installation or configuration. It is recommended to use different Target IP Addresses for each WAN interface. Example: 8.8.4.4
 
Last edited:
Do you think it's worth doing a check for the IP / Gateway changing for a WAN Interface? Typically if that happens it leaves state 2 and bounces out of the failover monitor to check WAN Status again.

Also I finished writing the readme after you restarted using the script where I called this out explicitly here. lol
Im probably in the minority on this situation, im not sure if other things do like that (cell,etc). I wouldnt worry about it. Mentioning in the readme is probably enough. As far as giving a like 15min delay on bootup. What do you think is best. get rid of the wan-event command for me, maybe add a script somewhere else
that does like a 'sleep 15m ; /jffs/scripts/wan-failover.sh cron' ? This would also just be for my situation obvisouly.
And far as the README, You probably need more then "recommending different ips for Wantarget" it just wont work, it creates two routes for the same ip, only one will.
 
Im probably in the minority on this situation, im not sure if other things do like that (cell,etc). I wouldnt worry about it. Mentioning in the readme is probably enough. As far as giving a like 15min delay on bootup. What do you think is best. get rid of the wan-event command for me, maybe add a script somewhere else
that does like a 'sleep 15m ; /jffs/scripts/wan-failover.sh cron' ? This would also just be for my situation obvisouly.

I already included a check for it in this beta. Test it out and report back any issues found. Are you saying you would like to have an option to append wan-event instead of it doing it during install?

v1.4.6-beta Link:

To Enable Email:
Code:
/jffs/scripts/wan-failover.sh email enable

To Disable Email:
Code:
/jffs/scripts/wan-failover.sh email disable

v1.4.6-beta Notes:
- Testing if Gateway or Interface change while actively monitoring, will return to WAN Status to recheck connection and recreate new routes.
- Testing email enable/disable function.
- Testing optimized logic for no arguments passed with script and 2nd argument options being added.
- Testing config options to not allow WAN0 and WAN1 Target IP Addresses to be the same during installation / configuration.
- Testing config options to now allow WAN0 and WAN1 Target IP Addresses to match their respective interface Gateway IP Address.

v1.4.4-beta Notes:
- Testing issue where WAN interface(s) were stuck in Cold Standby without an issued IP Address from a DHCP Server.
- Added beta version check for Update Mode.
 
Last edited:
I already included a check for it in this beta. Test it out and report back any issues found. Are you saying you would like to have an option to append wan-event instead of it doing it during install?

v1.4.5-beta Link:

v1.4.5-beta Notes:
- Testing email enable/disable function.
- Testing optimized logic for no arguments passed with script and 2nd argument options being added.
- Testing config options to not allow WAN0 and WAN1 Target IP Addresses to be the same during installation / configuration.

v1.4.4-beta Notes:
- Testing issue where WAN interface(s) were stuck in Cold Standby without an issued IP Address from a DHCP Server.
- Added beta version check for Update Mode.
In my situation, since the Starlink during like a power/cold boot can take up to 15minutes to come up.. Meaning it gives a fake ip (whatever it does), then after it searches for a sat,etc resends a working ip. I need a roughly 15 minute delay for wan-failover.sh to start. Normally ill know, can restart,etc,etc.. But if im not around
it totally breaks with the script. But if you included a check for wanip. I can test this.. But really i dont think id work to hard on this unless other users see it. I/We know the issue and can just do a workaround myself.
I think i can just add a command to like post mount
/jffs/scripts/myscript &
containing
#!/bin/sh
sleep 15m
/jffs/scripts/wan-failover.sh cron

?
 
Last edited:
In my situation, since the Starlink during like a power/cold boot can take up to 15minutes to come up.. Meaning it gives a fake ip (whatever it does), then after it searches for a sat,etc resends a working ip. I need a roughly 15 minute delay for wan-failover.sh to start. Normally ill know, can restart,etc,etc.. But if im not around
it totally breaks with the script. But if you included a check for wanip. I can test this.. But really i dont think id work to hard on this unless other users see it. I/We know the issue and can just do a workaround myself.
I think i can just add a command to like post mount
/jffs/scripts/myscript &
containing
#!/bin/sh
sleep 15m
/jffs/scripts/wan-failover.sh cron

?
Give me some data to work with and I can look into incorporating it, give me nvram show data at boot and 15 minutes later when you get the actual IP. I have an idea on how to get it to bounce back to redo check status, really just needs the IP routes created for the new Gateway / IP. I should be able to come up with a solution without you having to deviate away from the standard implementation. In the meantime, verify the changes in v1.4.5-beta and v1.4.4-beta are working for you if you don't mind.
 
Give me some data to work with and I can look into incorporating it, give me nvram show data at boot and 15 minutes later when you get the actual IP. I have an idea on how to get it to bounce back to redo check status, really just needs the IP routes created for the new Gateway / IP. I should be able to come up with a solution without you having to deviate away from the standard implementation. In the meantime, verify the changes in v1.4.5-beta and v1.4.4-beta are working for you if you don't mind.
ok, this may take me a few days. Ill probably just take it off dual-wan. Powercycle the Starlink and see whats happening during that period. Just a fyi, with the first gen starlinks people couldnt even use asus routers over this, i had read on it. Something about the lease time screwing up openwrt based routers, during the switch. But people with actual openwrt could change it.. The fix was to stick a switch inbetween the modem and router, which didnt really make sense to me.
Been awhile.
 
Last edited:
ok, this may take me a few days. Ill probably just take it off dual-wan. Powercycle the Starlink and see whats happening during that period
Actually disregard, I have an idea, about to upload a new beta for you to try.
 
look at my edited post, if it matters.
That may have to do with how the DHCP Querying is configured on your router, a little outside of the scope of this script but try playing with the different modes. Under WAN Settings.
 

Attachments

  • dhcpquery.png
    dhcpquery.png
    20.6 KB · Views: 46
That may have to do with how the DHCP Querying is configured on your router, a little outside of the scope of this script but try playing with the different modes.
Well thats what i mean, asus wrt dhcp was set hardcoded at like 1min or something, and that screwed up the timing with starlink. If I can ill find a link, not that it matters. I spend time on IRC #asuswrt and st users were having major issues before i even got mine.
 
Well thats what i mean, asus wrt dhcp was set hardcoded at like 1min or something, and that screwed up the timing with starlink. If I can ill find a link, not that it matters. I spend time on IRC #asuswrt and st users were having major issues before i even got mine.
What about restarting the WAN interface for Starlink? I updated my prior post with a new link to beta v1.4.6-beta.
 
You mean restarting eth0, which is connected to starlink? Ive done "service restart_wan_if 0".. doesnt seem to do much when it gets in that situation. I did not try to actually take take the interface down and up at that point.
 
You mean restarting eth0, which is connected to starlink? Ive done "service restart_wan_if 0".. doesnt seem to do much when it gets in that situation. I did not try to actually take take the interface down and up at that point.
Try changing your DHCP mode to continuous and see if that helps.
 
Try changing your DHCP mode to continuous and see if that helps.
ill try, but it literally takes ST 15 minutes to come up and give the proper ip in this situation (total restart). So im not sure what that would fix.
 
I already included a check for it in this beta. Test it out and report back any issues found. Are you saying you would like to have an option to append wan-event instead of it doing it during install?

v1.4.6-beta Link:

To Enable Email:
Code:
/jffs/scripts/wan-failover.sh email enable

To Disable Email:
Code:
/jffs/scripts/wan-failover.sh email disable

v1.4.6-beta Notes:
- Testing if Gateway or Interface change while actively monitoring, will return to WAN Status to recheck connection and recreate new routes.
- Testing email enable/disable function.
- Testing optimized logic for no arguments passed with script and 2nd argument options being added.
- Testing config options to not allow WAN0 and WAN1 Target IP Addresses to be the same during installation / configuration.
- Testing config options to now allow WAN0 and WAN1 Target IP Addresses to match their respective interface Gateway IP Address.

v1.4.4-beta Notes:
- Testing issue where WAN interface(s) were stuck in Cold Standby without an issued IP Address from a DHCP Server.
- Added beta version check for Update Mode.
I think you might have it now. With v1.4.6-beta i first just rebooted the starlink router, it came back up fine. Then i powered it off and on, it also came up perfect.
 
I think you might have it now. With v1.4.6-beta i first just rebooted the starlink router, it came back up fine. Then i powered it off and on, it also came up perfect.
And 15 minutes later it rechecks WAN Status when ST changes IP and comes back up correct? Also, did you get a chance to test any other features/changes from 1.4.6-beta?
 
Yep it did so fine.
Awesome, I did say I had an idea on handling that situation...lol. Glad it is working, I am going to be unavailable this weekend so 1.4.6-beta is going to stay on the beta channel until more testing can be done and then next week I can work on moving it to production as an available update.
 
Awesome, I did say I had an idea on handling that situation...lol. Glad it is working, I am going to be unavailable this weekend so 1.4.6-beta is going to stay on the beta channel until more testing can be done and then next week I can work on moving it to production as an available update.
appreciate very much the time you have put into it.
 

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