Hi,
we got a cloud core router with 2 wan connections. Connection type is LTE. As known there are sometimes troubles with the LTE connection so i made a backup for those connection (also LTE, but on a different location).
The script is currently working as expected, but it would be great if anybody can help me to improve the script.
The biggest problem is the flapping from netwatch. So if there any troubles on connection A netwatch detects that connection A is down and switch to B. But if connection A is back again in 1 minute it will imitiadly switch back.
My suggest is, that it only switch back if there are troubles with connection B. So i wouldn’t prefer to use always connection A.
The lot of switches kills everytime my ipsec tunnels.
/tool netwatch
add down-script=WAN1_Down host=172.28.xxx.xxx interval=10s timeout=800ms up-script=WAN1_UP
WAN1_Down
interface ethernet enable WAN2
ip route set [/ip route find dst-address=0.0.0.0/0] gateway=192.168.20.1
:foreach i in [/ip firewall nat find] do={
:if ("." . [:find [/ip firewall nat get $i comment] "WAN1"] . "."!="..") do={
/ip firewall nat set $i disabled=yes
}
}
:foreach i in [/ip firewall nat find] do={
:if ("." . [:find [/ip firewall nat get $i comment] "WAN2"] . "."!="..") do={
/ip firewall nat set $i disabled=no
}
}
:foreach i in [/ip firewall filter find] do={
:if ("." . [:find [/ip firewall filter get $i comment] "WAN1"] . "."!="..") do={
/ip firewall filter set $i disabled=yes
}
}
:foreach i in [/ip firewall filter find] do={
:if ("." . [:find [/ip firewall filter get $i comment] "WAN2"] . "."!="..") do={
/ip firewall filter set $i disabled=no
}
}
:foreach i in [/ip ipsec policy find] do={
:if ("." . [:find [/ip ipsec policy get $i comment] "normal"] . "."!="..") do={
/ip ipsec policy set $i disabled=yes
}
}
:foreach i in [/ip ipsec policy find] do={
:if ("." . [:find [/ip ipsec policy get $i comment] "backup"] . "."!="..") do={
/ip ipsec policy set $i disabled=no
}
}
ip ipsec remote-peers kill-connections
And currently i have added a route that the ping to the check-host can only go trough wan1 and not wan2. So i can ping instead if WAN2 is the primary connection. To prefent that ping goes trough wan2 i also installed a firewall rule.
So thats it,
i hope anybody can help me.
Thanks!