dual wan failover with traffic monitor script

i have dualwan failover how can i incorporate the traffic monitor script so that the scenario will be wan1 will be the default source and when wan1 reach the threshold in traffic monitor wan2 will kicks in to help the bandwidth of wan1?thanks in advance


/ip firewall nat
add action=masquerade chain=srcnat disabled=no out-interface=WAN1
add action=masquerade chain=srcnat disabled=no out-interface=WAN2
/ip route
add dst-address=8.8.8.8 gateway=192.168.1.1 scope=10
add dst-address=221.132.112.8 gateway=192.168.2.1 scope=10

add distance=1 gateway=8.8.8.8 check-gateway=ping
add distance=2 gateway=221.132.112.8 check-gateway=ping




/system script
add name=eth-up source={/interface enable ether2}
add name=eth-down source={/interface disable ether2}
/tool traffic-monitor
add name=turn_on interface=ether1 on-event=eth-up threshold=15000 trigger=above traffic=received
add name=turn_off interface=ether1 on-event=eth-down threshold=12000 trigger=below traffic=received

All of your traffic will naturally flow out your default gateway, which I assume is the 8.8.8.8 route? To use the 2nd WAN, you will have to identify the traffic to go out the 2nd WAN and direct it through that gateway. There are many ways to do this such as ECMP, PCC, PBR, ect. Using Mangle to mark the traffic and direct it out that gateway is something that could be easily scripted with your scenario. There are several examples on the Wiki of how to do that (minus the traffic monitor portion).