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!

nvram set wan1_state_t=2 && service “restart_wan_if=1”

The second WAN in the router's web interface became hot, but the script did not exit the loop.

Ok send logs and nvram output again after you ran the command so I can see what loop is faulting, it is either not making it out or wan status check or bouncing to wan disabled and meeting a break out condition to go back.
 
Im sure you know it more then me, but when starlink would lose signal, it would switchover. And the basic router/ethernet connection was still up.
Why would it do ping monitoring to like google or microsoft if it just wanted a link?
Their method is great for failover which is basically the same as mine, their failback is where there is a flaw. So it monitors for ping failure similar to mine and then fail over and mine does the same for failback.
 
nvram set wan1_state_t=2 && service “restart_wan_if 1” unsigned equals returns an error
Usage: service <action_service>
 
nvram set wan1_state_t=2 && service “restart_wan_if 1” unsigned equals returns an error
Usage: service <action_service>
that does same on mine,
just try them separate..
nvram set wan_1_state_t=2
service "restart_wan_if 1"
 
that does same on mine,
just try them separate..
nvram set wan_1_state_t=2
service "restart_wan_if 1"
Sorry I’m on my phone and assumed they would both execute ok…try them separately as @rlj2 stated.
 
nvram set wan1_state_t=2 && service "restart_wan_if 1"

All ok!!! Thanks

I think only service "restart_wan_if 1" is enough



p.s. There were incorrect quotes in one message, an error was given with them
 
nvram set wan1_state_t=2 && service "restart_wan_if 1"

All ok!!! Thanks

I think only service "restart_wan_if 1" is enough



p.s. There were incorrect quotes in one message, an error was given with them

Ah yes I see my typo, lol apologies I’m on my phone atm! @rlj2 can you send me an output of your nvram too using the following command before you do a wan interface restart. I think I see a solution but want to confirm, this appears to be something you guys with a double NAT experience and I have to make a condition to handle it.

Code:
nvram show | grep -e “wan1”
 
I think we need to add service "restart_wan_if 1" to the initial start of the script so that there is no need to add it to post-mount or anywhere else.
That's it, the problem is solved, the stock switch of the asus is no longer needed.
 
Ah yes I see my typo, lol apologies I’m on my phone atm! @rlj2 can you send me an output of your nvram too using the following command before you do a wan interface restart. I think I see a solution but want to confirm, this appears to be something you guys with a double NAT experience and I have to make a condition to handle it.

Code:
nvram show | grep -e “wan1”
I don't understand exactly at what moment and after what command and with what conditions. I have already executed such a command before and after, no,?
 
I think we need to add service "restart_wan_if 1" to the initial start of the script so that there is no need to add it to post-mount or anywhere else.
That's it, the problem is solved, the stock switch of the asus is no longer needed.

I am going to add it back but I need it to only execute for a specific condition other wise it is an unecessary restart, this is why I need the nvram data request pre and post restart commands so I can develop a check that will account for this and restart the interface. It is not a universal problem so I don’t want to make a universal action for everyone.
 
Ah yes I see my typo, lol apologies I’m on my phone atm! @rlj2 can you send me an output of your nvram too using the following command before you do a wan interface restart. I think I see a solution but want to confirm, this appears to be something you guys with a double NAT experience and I have to make a condition to handle it.

Code:
nvram show | grep -e “wan1”
fyi, that command gives no output on my router. youve posted -e "wan1" before, it doesnt work here.. but heres the output of nvram show|grep wan1
Secondary is cold right now.

Code:
admin@RT-AX86U-D7D0:/tmp/home/root# nvram show | grep wan1
link_wan1=1
switch_wan1prio=0
switch_wan1tagid=
wan1_6rd_ip4size=
wan1_6rd_prefix=
wan1_6rd_prefixlen=
wan1_6rd_router=
wan1_auth_x=
wan1_auxstate_t=0
wan1_clientid=
wan1_clientid_type=0
wan1_desc=
wan1_dhcp_qry=1
wan1_dhcpenable_x=1
wan1_dns=
wan1_dns1_x=1.1.1.1
wan1_dns2_x=8.8.8.8
wan1_dnsenable_x=1
wan1_enable=1
wan1_expires=45
wan1_gateway=0.0.0.0
wan1_gateway_x=0.0.0.0
wan1_gw_ifname=eth5
wan1_gw_mac=04:D4:C4:B6:14:40
wan1_heartbeat_x=
wan1_hostname=
wan1_hwaddr=24:4B:FE:2F:D7:D1
wan1_hwaddr_x=
wan1_hwname=
wan1_ifname=eth5
wan1_ipaddr=0.0.0.0
wan1_ipaddr_x=0.0.0.0
wan1_is_usb_modem_ready=0
wan1_mroute=
wan1_mtu=1500
wan1_nat_x=1
wan1_netmask=0.0.0.0
wan1_netmask_x=0.0.0.0
wan1_phytype=
wan1_ppp_echo=1
wan1_ppp_echo_failure=10
wan1_ppp_echo_interval=6
wan1_pppoe_ac=
wan1_pppoe_auth=
size: 75433 bytes (55639 left)
wan1_pppoe_hostuniq=
wan1_pppoe_idletime=0
wan1_pppoe_ifname=
wan1_pppoe_mru=1492
wan1_pppoe_mtu=1492
wan1_pppoe_options_x=
wan1_pppoe_passwd=
wan1_pppoe_relay=0
wan1_pppoe_service=
wan1_pppoe_username=
wan1_pptp_options_x=
wan1_primary=0
wan1_proto=dhcp
wan1_proto_t=
wan1_realip_ip=
wan1_realip_state=0
wan1_route=
wan1_s46_ealen_x=0
wan1_s46_offset_x=6
wan1_s46_peer_x=
wan1_s46_prefix4_x=
wan1_s46_prefix4len_x=0
wan1_s46_prefix6_x=
wan1_s46_prefix6len_x=0
wan1_s46_psid_x=0
wan1_s46_psidlen_x=0
wan1_sbstate_t=0
wan1_state_t=4
wan1_unit=1
wan1_upnp_enable=1
wan1_vendorid=
wan1_vpndhcp=1
wan1_wins=
wan1_xgateway=0.0.0.0
wan1_xipaddr=0.0.0.0
wan1_xnetmask=0.0.0.0
 
After the restart and hot, does it really hurt anything to just restart the secondary?

Code:
admin@RT-AX86U-D7D0:/jffs/scripts# nvram show | grep wan1
link_wan1=1
switch_wan1prio=0
switch_wan1tagid=
wan1_6rd_ip4size=
wan1_6rd_prefix=
wan1_6rd_prefixlen=
wan1_6rd_router=
wan1_auth_x=
wan1_auxstate_t=0
wan1_clientid=
wan1_clientid_type=0
wan1_desc=
wan1_dhcp_qry=1
wan1_dhcpenable_x=1
wan1_dns=192.168.10.1
wan1_dns1_x=1.1.1.1
wan1_dns2_x=8.8.8.8
wan1_dnsenable_x=1
wan1_enable=1
wan1_expires=86692
wan1_gateway=192.168.10.1
wan1_gateway_x=0.0.0.0
wan1_gw_ifname=eth5
wan1_gw_mac=04:D4:C4:B6:14:40
wan1_heartbeat_x=
wan1_hostname=
wan1_hwaddr=24:4B:FE:2F:D7:D1
wan1_hwaddr_x=
wan1_hwname=
wan1_ifname=eth5
wan1_ipaddr=192.168.10.189
wan1_ipaddr_x=0.0.0.0
wan1_is_usb_modem_ready=0
wan1_lease=86400
wan1_mroute=
wan1_mtu=1500
wan1_nat_x=1
wan1_netmask=255.255.255.0
wan1_netmask_x=0.0.0.0
wan1_phytype=
wan1_ppp_echo=1
wan1_ppp_echo_failure=10
wan1_ppp_echo_interval=6
wan1_pppoe_ac=
wan1_pppoe_auth=
wan1_pppoe_hostuniq=
wan1_pppoe_idletime=0
wan1_pppoe_ifname=
wan1_pppoe_mru=1492
wan1_pppoe_mtu=1492
wan1_pppoe_options_x=
wan1_pppoe_passwd=
wan1_pppoe_relay=0
wan1_pppoe_service=
wan1_pppoe_username=
wan1_pptp_options_x=
wan1_primary=0
wan1_proto=dhcp
wan1_proto_t=dhcp
wan1_realip_ip=
wan1_realip_state=0
wan1_route=
wan1_s46_ealen_x=0
wan1_s46_offset_x=6
wan1_s46_peer_x=
wan1_s46_prefix4_x=
wan1_s46_prefix4len_x=0
wan1_s46_prefix6_x=
wan1_s46_prefix6len_x=0
wan1_s46_psid_x=0
size: 75492 bytes (55580 left)
wan1_s46_psidlen_x=0
wan1_sbstate_t=0
wan1_state_t=2
wan1_unit=1
wan1_upnp_enable=1
wan1_vendorid=
wan1_vpndhcp=1
wan1_wins=
wan1_xgateway=192.168.10.1
wan1_xipaddr=0.0.0.0
wan1_xnetmask=0.0.0.0
 
Ah yes I see my typo, lol apologies I’m on my phone atm! @rlj2 can you send me an output of your nvram too using the following command before you do a wan interface restart. I think I see a solution but want to confirm, this appears to be something you guys with a double NAT experience and I have to make a condition to handle it.

Code:
nvram show | grep -e “wan1”
before

Code:
link_wan1=1
switch_wan1prio=0
switch_wan1tagid=
wan1_6rd_ip4size=
wan1_6rd_prefix=
wan1_6rd_prefixlen=
wan1_6rd_router=
wan1_auth_x=
wan1_auxstate_t=0
wan1_clientid=
wan1_clientid_type=0
wan1_desc=
wan1_dhcp_qry=1
wan1_dhcpenable_x=1
wan1_dns=10.100.0.1
wan1_dns1_x=10.100.0.1
wan1_dns2_x=
wan1_dnsenable_x=1
wan1_enable=1
wan1_expires=86438
wan1_gateway=10.100.0.1
wan1_gateway_x=10.100.0.1
wan1_gw_ifname=eth2
wan1_gw_mac=8C:88:2B:CC:2E:2E
wan1_heartbeat_x=
wan1_hostname=
wan1_hwaddr=04:D4:CC:51:30:C9
wan1_hwaddr_x=
wan1_hwname=
wan1_ifname=eth2
wan1_ipaddr=10.100.0.2
wan1_ipaddr_x=10.100.0.2
wan1_is_usb_modem_ready=0
wan1_lease=86400
wan1_mroute=
wan1_mtu=1500
wan1_nat_x=1
wan1_netmask=255.255.255.0
wan1_netmask_x=255.255.255.0
wan1_phytype=
wan1_ppp_echo=1
wan1_ppp_echo_failure=10
wan1_ppp_echo_interval=6
wan1_ppp_phy=0
wan1_pppoe_ac=
wan1_pppoe_auth=
wan1_pppoe_hostuniq=
wan1_pppoe_idletime=0
wan1_pppoe_ifname=
wan1_pppoe_mru=1492
wan1_pppoe_mtu=1492
wan1_pppoe_options_x=
wan1_pppoe_passwd=
wan1_pppoe_relay=0
wan1_pppoe_service=
wan1_pppoe_username=
wan1_pptp_options_x=
wan1_primary=0
wan1_proto=dhcp
wan1_proto_t=
wan1_realip_ip=
wan1_realip_state=0
wan1_route=
wan1_sbstate_t=0
wan1_state_t=4
wan1_unit=1
wan1_upnp_enable=0
wan1_vendorid=
wan1_vpndhcp=1
wan1_wins=
wan1_xgateway=10.100.0.1
wan1_xipaddr=0.0.0.0
wan1_xnetmask=0.0.0.0

after after service "restart_wan_if 1"

Code:
link_wan1=1
switch_wan1prio=0
switch_wan1tagid=
wan1_6rd_ip4size=
wan1_6rd_prefix=
wan1_6rd_prefixlen=
wan1_6rd_router=
wan1_auth_x=
wan1_auxstate_t=0
wan1_clientid=
wan1_clientid_type=0
wan1_desc=
wan1_dhcp_qry=1
wan1_dhcpenable_x=1
wan1_dns=10.100.0.1
wan1_dns1_x=10.100.0.1
wan1_dns2_x=
wan1_dnsenable_x=1
wan1_enable=1
wan1_expires=86616
wan1_gateway=10.100.0.1
wan1_gateway_x=10.100.0.1
wan1_gw_ifname=eth2
wan1_gw_mac=8C:88:2B:CC:2E:2E
wan1_heartbeat_x=
wan1_hostname=
wan1_hwaddr=04:D4:CC:51:30:C9
wan1_hwaddr_x=
wan1_hwname=
wan1_ifname=eth2
wan1_ipaddr=10.100.0.2
wan1_ipaddr_x=10.100.0.2
wan1_is_usb_modem_ready=0
wan1_lease=86400
wan1_mroute=
wan1_mtu=1500
wan1_nat_x=1
wan1_netmask=255.255.255.0
wan1_netmask_x=255.255.255.0
wan1_phytype=
wan1_ppp_echo=1
wan1_ppp_echo_failure=10
wan1_ppp_echo_interval=6
wan1_ppp_phy=0
wan1_pppoe_ac=
wan1_pppoe_auth=
wan1_pppoe_hostuniq=
wan1_pppoe_idletime=0
wan1_pppoe_ifname=
wan1_pppoe_mru=1492
wan1_pppoe_mtu=1492
wan1_pppoe_options_x=
wan1_pppoe_passwd=
wan1_pppoe_relay=0
wan1_pppoe_service=
wan1_pppoe_username=
size: 90867 bytes (40205 left)
wan1_pptp_options_x=
wan1_primary=0
wan1_proto=dhcp
wan1_proto_t=dhcp
wan1_realip_ip=
wan1_realip_state=0
wan1_route=
wan1_sbstate_t=0
wan1_state_t=2
wan1_unit=1
wan1_upnp_enable=0
wan1_vendorid=
wan1_vpndhcp=1
wan1_wins=
wan1_xgateway=10.100.0.1
wan1_xipaddr=0.0.0.0
wan1_xnetmask=0.0.0.0

compare:
Code:
wan1_expires=86438
wan1_proto_t=
wan1_state_t=4

wan1_expires=86616
wan1_proto_t=dhcp
wan1_state_t=2
 
After the restart and hot, does it really hurt anything to just restart the secondary?

Code:
admin@RT-AX86U-D7D0:/jffs/scripts# nvram show | grep wan1
link_wan1=1
switch_wan1prio=0
switch_wan1tagid=
wan1_6rd_ip4size=
wan1_6rd_prefix=
wan1_6rd_prefixlen=
wan1_6rd_router=
wan1_auth_x=
wan1_auxstate_t=0
wan1_clientid=
wan1_clientid_type=0
wan1_desc=
wan1_dhcp_qry=1
wan1_dhcpenable_x=1
wan1_dns=192.168.10.1
wan1_dns1_x=1.1.1.1
wan1_dns2_x=8.8.8.8
wan1_dnsenable_x=1
wan1_enable=1
wan1_expires=86692
wan1_gateway=192.168.10.1
wan1_gateway_x=0.0.0.0
wan1_gw_ifname=eth5
wan1_gw_mac=04:D4:C4:B6:14:40
wan1_heartbeat_x=
wan1_hostname=
wan1_hwaddr=24:4B:FE:2F:D7:D1
wan1_hwaddr_x=
wan1_hwname=
wan1_ifname=eth5
wan1_ipaddr=192.168.10.189
wan1_ipaddr_x=0.0.0.0
wan1_is_usb_modem_ready=0
wan1_lease=86400
wan1_mroute=
wan1_mtu=1500
wan1_nat_x=1
wan1_netmask=255.255.255.0
wan1_netmask_x=0.0.0.0
wan1_phytype=
wan1_ppp_echo=1
wan1_ppp_echo_failure=10
wan1_ppp_echo_interval=6
wan1_pppoe_ac=
wan1_pppoe_auth=
wan1_pppoe_hostuniq=
wan1_pppoe_idletime=0
wan1_pppoe_ifname=
wan1_pppoe_mru=1492
wan1_pppoe_mtu=1492
wan1_pppoe_options_x=
wan1_pppoe_passwd=
wan1_pppoe_relay=0
wan1_pppoe_service=
wan1_pppoe_username=
wan1_pptp_options_x=
wan1_primary=0
wan1_proto=dhcp
wan1_proto_t=dhcp
wan1_realip_ip=
wan1_realip_state=0
wan1_route=
wan1_s46_ealen_x=0
wan1_s46_offset_x=6
wan1_s46_peer_x=
wan1_s46_prefix4_x=
wan1_s46_prefix4len_x=0
wan1_s46_prefix6_x=
wan1_s46_prefix6len_x=0
wan1_s46_psid_x=0
size: 75492 bytes (55580 left)
wan1_s46_psidlen_x=0
wan1_sbstate_t=0
wan1_state_t=2
wan1_unit=1
wan1_upnp_enable=1
wan1_vendorid=
wan1_vpndhcp=1
wan1_wins=
wan1_xgateway=192.168.10.1
wan1_xipaddr=0.0.0.0
wan1_xnetmask=0.0.0.0
It slows down the ready state for failover monitoring unnecessarily but I found a condition to look for to do the restart, state_t 4 seems to be what the machines stuck in double NAT appear to be with no real IP.
 
Last edited:

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