„src/change-defaultRoute.pl“ hinzufügen
parent
6759120a1d
commit
3c491fe2c5
|
@ -0,0 +1,49 @@
|
||||||
|
# for this you
|
||||||
|
# this script depends on 5 routes
|
||||||
|
# 1. with the comment "MAINGW" this will be always changed depends on if DSL is available
|
||||||
|
# 2. with comment "DSL" this is your route where normally all your traffic goes
|
||||||
|
# 3. 1.1.1.1 over DSL fixed
|
||||||
|
# 4. with comment "LTE" if ping to 1.1.1.1 fails
|
||||||
|
# 5. route to your uptime kuma,
|
||||||
|
#
|
||||||
|
# uptime kuma is externally hosted and only available over a vpn
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
:local LanInterface ether1
|
||||||
|
|
||||||
|
:local PingTargetOne 1.1.1.1
|
||||||
|
:local FailThreshholdOne 3
|
||||||
|
|
||||||
|
:global PingFailCountOne
|
||||||
|
|
||||||
|
:local maingw [/ip route get [find comment="MAINGW"] gateway ];
|
||||||
|
:local dslgw [/ip route get [find comment="DSL"] gateway ];
|
||||||
|
:local ltegw [/ip route get [find comment="LTE"] gateway ];
|
||||||
|
|
||||||
|
:set $PingResult [ping 1.1.1.1 count=1]
|
||||||
|
:put $PingResult
|
||||||
|
|
||||||
|
:if ($PingResult = 0) do={
|
||||||
|
:if ($PingFailCountONE < ($FailTresholdOne+2)) do={
|
||||||
|
:set $PingFailCountOne ($PingFailCountOne + 1)
|
||||||
|
:log warning "Ping to $PingTargetONE failed."
|
||||||
|
|
||||||
|
:if ( PingFailCountOne >= $FailTreshold) do={
|
||||||
|
:log warning "Change default route to LTE Backup!"
|
||||||
|
:log info "Change default route to LTE Backup!"
|
||||||
|
|
||||||
|
/ip route set [find comment="MAINGW"] gateway=$ltegw
|
||||||
|
/ip route set [find comment="UPTIME_KUMA"] type=blackhole
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
:if ($PingResult = 1) do={
|
||||||
|
:if ($PingFailCountOne > 0) do={
|
||||||
|
:set PingFailCountOne 0
|
||||||
|
:log info "Reset route to DSL"
|
||||||
|
/ip route set [find comment="MAINGW"] gateway=$dslgw
|
||||||
|
/ip route set [find comment="UPTIME_KUMA"] type=unicast
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue