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!

Shows not only the IP, but also the domain name.

***WAN Failback Notification***
----------------------------------------------------------------------------------------
Hostname: sinema.asuscomm.com
Event Time: Jul 19 15:21:23
Active ISP:
WAN IPv4 Address: 178.249.55.33
WAN Gateway IP Address: 178.249.55.254
WAN Interface: eth0
DNS: Managed by AdGuardHome
QoS Status: Enabled
QoS Mode: Manual Settings
QoS Download Bandwidth: 100Mbps
QoS Upload Bandwidth: 100Mbps
QoS WAN Packet Overhead: 48

***WAN Load Balancing Notification***
----------------------------------------------------------------------------------------
Hostname:sinema.asuscomm.com
Event Time: Jul 19 20:57:52
WAN0 IPv4 Address: 178.249.55.33
WAN0 Status: DISCONNECTED
WAN1 IPv4 Address: 192.168.199.100
WAN1 Status: CONNECTED

In his situation, he is dealing with NAT’d IPs as his interface IPs so the email for him would not be sufficient to know his actual WAN, I can build additional logic around this for Failover Mode. LB mode would be a little more challenging.
 
In his situation, he is dealing with NAT’d IPs as his interface IPs so the email for him would not be sufficient to know his actual WAN, I can build additional logic around this for Failover Mode. LB mode would be a little more challenging.
Why if it's a white IP? I get the same situation, but nevertheless everything is determined.
 
Ah good point, because of double NAT or CGNAT you aren’t able to see your actual IP. I like that and will look into it. I’m debating on leaving the recursive checks feature in place or not. Thoughts?
This is a very good fcnction. This function is actually very useful, for example, on a not very stable line.
 
Shows not only the IP, but also the domain name.

***WAN Failback Notification***
----------------------------------------------------------------------------------------
Hostname: sinema.asuscomm.com
Event Time: Jul 19 15:21:23
Active ISP:
WAN IPv4 Address: 178.249.55.33
WAN Gateway IP Address: 178.249.55.254
WAN Interface: eth0
DNS: Managed by AdGuardHome
QoS Status: Enabled
QoS Mode: Manual Settings
QoS Download Bandwidth: 100Mbps
QoS Upload Bandwidth: 100Mbps
QoS WAN Packet Overhead: 48

***WAN Load Balancing Notification***
----------------------------------------------------------------------------------------
Hostname:sinema.asuscomm.com
Event Time: Jul 19 20:57:52
WAN0 IPv4 Address: 178.249.55.33
WAN0 Status: DISCONNECTED
WAN1 IPv4 Address: 192.168.199.100
WAN1 Status: CONNECTED
I have a backup line everywhere, it's not a permanent external ip. The interface of the modem itself naturally does not change ip, but the external ip is changing all the time. Besides, he's white, not nat.(I pay 90 rublesto MTS a month). It would be useful to know this ip when switching to a backup line, then I will be able to reach my main router from the outside.
 
Why if it's a white IP? I get the same situation, but nevertheless everything is determined.
the 4g Modem I have is not inserted directly, not into the router, but into an intermediate Chinese device.
I generally get a 3-nat ;) But everything works, I threw everything through the DMZ everywhere. (4g modem DMZ to client: mango, mango DMZ to client: router)
 
Last edited:
This is a very good fcnction. This function is actually very useful, for example, on a not very stable line.
At the same time though users can increase the ping count to account for the instability.
 
At the same time though users can increase the ping count to account for the instability.
It's not quite right. Indeed, to set up the line at the initial load, exactly 0% is needed. If this function does not greatly interfere with others, why not leave it, just set it to 1 by default and that's it. Even when installing script, do not ask for setting. Inly manual setting.
 
It's not quite right. Indeed, to set up the line at the initial load, exactly 0% is needed. If this function does not greatly interfere with others, why not leave it, just set it to 1 by default and that's it. Even when installing script, do not ask for setting. Inly manual setting.
That's how it is now, I'll leave it and recommend not to change unless necessary.
 
I have a backup line everywhere, it's not a permanent external ip. The interface of the modem itself naturally does not change ip, but the external ip is changing all the time. Besides, he's white, not nat.(I pay 90 rublesto MTS a month). It would be useful to know this ip when switching to a backup line, then I will be able to reach my main router from the outside.
What is useful?
 
the 4g Modem I have is not inserted directly, not into the router, but into an intermediate Chinese device.
I generally get a 3-nat ;) But everything works, I threw everything through the DMZ everywhere.
I do not see any problems that I do not know the external ip of the mobile provider, especially since you have it white and it will not change. Yes, and I know what and how it works for you, we talked on 4pda.
 
What is useful?
I do not see any problems that I do not know the external ip of the mobile provider, especially since you have it white and it will not change. Yes, and I know what and how it works for you, we talked on 4pda.
I have a lot of services up at home. And I want to be able to connect to them even when router connected to backup line. Another thing is that I have already implemented it so that when I change my ip, my subdomain also changes. But if this script would also give an external ip and not internal ip(if 2nat), it could be useful, for example, if the main one suddenly did not work.
 
v1.5.6-beta3 Release: ***Disclaimer: This is a beta release and has been untested***

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.6-beta3.sh" -o "/jffs/scripts/wan-failover.sh" && chmod 755 /jffs/scripts/wan-failover.sh && sh /jffs/scripts/wan-failover.sh restart

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

***WARNING: IPv6 issues may occur from new service restart logic during failover, please test and provide debug logging data if you experience issues***
***WARNING: If using IPv6 6in4 while in Load Balance Mode, verify new configuration options in .conf file are correct. See Release Notes***



Release Notes:
v1.5.6-beta3
- General optimization
- Added a confirmation prompt to Restart Mode.
- Fixed visual bugs when running Restart Mode.
- Load Balance Monitor now triggers Service Restart function during failover events.
- IPv6 services are restarted for Failover events.
- YazFi trigger during service restart will no longer run process in the background to prevent issues with script execution of YazFi.
- IP Rules should no longer create conflict with other scripts such as VPNMON.
- Target IPs for both interfaces can now be the same the Target IP.
- Added Recursive Ping Check feature. If packet loss is not 0% during a check, the Target IP Addresses will be checked again based on the number of iterations specified by this setting before determing a failure or packet loss. RECURSIVEPINGCHECK (Value is in # of iterations). Default: 1
- Resolved issues that prevented 4G USB Devices from properly working in Failover Mode.
- Moved BOOTDELAYTIMER, PACKETLOSSLOGGING and WANDISABLEDSLEEPTIMER to Optional Configuration and no longer are required to be set during Config or Installation. They will be given Default values that can be modified in the Configuration file.
- Created new Optional Configuration Options for using IPv6 6in4 Service while in Load Balance Mode. 6IN4INTERFACE will specify which WAN Interface to use for the IPv6 6in4 Tunnel, Default: wan0. 6IN4RULEPRIORITY will specify the IP Rule priority, Default: 100.
- Created new Optional Configured Option to specify the ping packet size. PACKETSIZE specifes the packet size in Bytes, Default: 56 Bytes.
 
Last edited:
v1.5.6-beta3 Release: ***Disclaimer: This is a beta release and has been untested***

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.6-beta3.sh" -o "/jffs/scripts/wan-failover.sh" && chmod 755 /jffs/scripts/wan-failover.sh && sh /jffs/scripts/wan-failover.sh restart

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

***WARNING: IPv6 issues may occur from new service restart logic during failover, please test and provide debug logging data if you experience issues***
***WARNING: If using IPv6 6in4 while in Load Balance Mode, verify new configuration options in .conf file are correct. See Release Notes***



Release Notes:
v1.5.6-beta3
- General optimization
- Added a confirmation prompt to Restart Mode.
- Fixed visual bugs when running Restart Mode.
- Load Balance Monitor now triggers Service Restart function during failover events.
- IPv6 services are restarted for Failover events.
- YazFi trigger during service restart will no longer run process in the background to prevent issues with script execution of YazFi.
- IP Rules should no longer create conflict with other scripts such as VPNMON.
- Target IPs for both interfaces can now be the same the Target IP.
- Added Recursive Ping Check feature. If packet loss is not 0% during a check, the Target IP Addresses will be checked again based on the number of iterations specified by this setting before determing a failure or packet loss. RECURSIVEPINGCHECK (Value is in # of iterations). Default: 1
- Resolved issues that prevented 4G USB Devices from properly working in Failover Mode.
- Moved BOOTDELAYTIMER, PACKETLOSSLOGGING and WANDISABLEDSLEEPTIMER to Optional Configuration and no longer are required to be set during Config or Installation. They will be given Default values that can be modified in the Configuration file.
- Created new Optional Configuration Options for using IPv6 6in4 Service while in Load Balance Mode. INTERFACE6IN4 will specify which WAN Interface to use for the IPv6 6in4 Tunnel, Default: wan0. RULEPRIORITY6IN4 will specify the IP Rule priority, Default: 100.
I will once again ask one point. I didn't really understand the answer. wan1 is monitored constantly? I'm interested in this, because traffic on it is paid. If it is monitored all the time, is it possible to make the ping frequency more rare or will wan0 and wan1 have the same ping frequency setting?

p.s,. And I think this line somehow looks wrong now, NO? "WAN0 Failover Monitor - Monitoring wan1 via 1.0.0.1 for Failure.".
 
Last edited:
I will once again ask one point. I didn't really understand the answer. wan1 is monitored constantly? I'm interested in this, because traffic on it is paid. If it is monitored all the time, is it possible to make the ping frequency more rare or will wan0 and wan1 have the same ping frequency setting?

p.s,. And I think this line somehow looks wrong now, NO? "WAN0 Failover Monitor - Monitoring wan1 via 1.0.0.1 for Failure.".
They are both actively monitored but the logging for Failover Mode will not show this.
 
They are both actively monitored but the logging for Failover Mode will not show this.
Is it possible to do something so that wan1 monitors less diligently? :) Otherwise, the script will gobble up half of my traffic ;)))

After all, in fact, there is no need to constantly monitor wan1. For me, let's say once every 1 or 10 or 60 minutes and when switching to wan1 it would be enough
 
Is it possible to do something so that wan1 monitors less diligently? :) Otherwise, the script will gobble up half of my traffic ;)))

After all, in fact, there is no need to constantly monitor wan1. For me, let's say once every 1 or 10 or 60 minutes and when switching to wan1 it would be enough

1. I will look into what I can do for this.
2. Is the ICMP traffic enough to be of concerned for your data limits?
3. Could you set your WAN1 Target to something like the WAN1 Gateway IP or a DNS Server for that interface so it wouldn’t hurt your bandwidth?
 
1. I will look into what I can do for this.
2. Is the ICMP traffic enough to be of concerned for your data limits?
3. Could you set your WAN1 Target to something like the WAN1 Gateway IP or a DNS Server for that interface so it wouldn’t hurt your bandwidth?

2. Not much, of course, but I have 25 gb in month for many devices: 3 reserves for routes, wifi in the car, etc. Right now, I'm using a router about 500kb per hour, which is roughly 0.35gb per month for one router
3. Very good idea. I can also try to ping the internal resources of mts, which are supposedly free, I'll try.
 
2. Not much, of course, but I have 25 gb in month for many devices: 3 reserves for routes, wifi in the car, etc. Right now, I'm using a router about 500kb per hour, which is roughly 0.35gb per month for one router
3. Very good idea. I can also try to ping the internal resources of mts, which are supposedly free, I'll try.

What if I allow an option to specify the ping packet size outside of the default (56 bytes I believe)?
 
What if I allow an option to specify the ping packet size outside of the default (56 bytes I believe)?

Let's try. so far I see I have more than 1mb per hour spent;) (I also ping from outside once a minute in the hetrixtools.com service

p.s. I configured to ping mts host 178.248.238.27 , I'll see what happens.
 
Let's try. so far I see I have more than 1mb per hour spent;) (I also ping from outside once a minute in the hetrixtools.com service

p.s. I configured to ping mts host 178.248.238.27 , I'll see what happens.
Republished beta3 to include a PACKETSIZE option in the config file, default is 56 bytes.
 

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