Community discussions

MikroTik App
 
freedarwuin
just joined
Topic Author
Posts: 2
Joined: Fri Feb 24, 2012 5:04 pm

Failover V5 funciona pero en la V6 no Help

Fri Mar 10, 2017 5:40 am

:local inter ("WAN1")
:local ipPing ("204.117.214.10")
:global oldGatewayETHER1WAN1
:global totalrunETHER1WAN1
:global infoETHER1WAN1
:global statsETHER1WAN1

:if ([:len [$totalrunETHER1WAN1]] = 0) do={
:set totalrunETHER1WAN1 "1"
} else={
:set totalrunETHER1WAN1 ($totalrunETHER1WAN1+1)
}

:if ([:len [$statsETHER1WAN1]] = 0) do={
:set statsETHER1WAN1 "x"
} else={
:set statsETHER1WAN1 ("$infoETHER1WAN1 / $totalrunETHER1WAN1")
}

:if ([:len [$oldGatewayETHER1WAN1]] < 3) do={
:set oldGatewayETHER1WAN1 "0.0.0.0"
}
:log info ("$inter: $inter" . ": PARTE 1")
/ip dhcp-client enable [find interface=$inter]
:delay 10s
:local pingip
:local cGateway [/ip dhcp-client get [find interface=$inter] gateway]
:log info ("$inter: cGateway --> $cGateway")
/ip route {
:foreach i in=[find comment=("ping_$inter")] do={
:log info ("$inter: ping_$inter")
/ip route remove $i
}
}
/ip route add distance=1 dst-address=$ipPing gateway=("$cGateway%$inter") comment=("ping_$inter")
:set pingip [/ping $ipPing count=10]
:log info ("$inter --> begin pinging")
:if ($pingip = 0) do={
:set infoETHER1WAN1 ($infoETHER1WAN1+1)
:log info ("$inter --> pinging: $pingip")
/ip dhcp-client disable [find interface=$inter]
/ip route disable [find comment=$inter]
/ip firewall mangle disable [find comment=$inter]
} else={
/ip route enable [find comment=$inter]
/ip firewall mangle enable [find comment=$inter]
}
:log info ("$inter --> end pinging")
:log info ("$inter: $inter" . ": PARTE 2")
:local j
:local cGateway [/ip dhcp-client get [find interface=$inter] gateway]
:local cWlan ($inter . "-" . $cGateway)
:local fWlan ($inter . "-" . $oldGatewayETHER1WAN1)
:log info ("$inter: Gateway in file: " . $oldGatewayETHER1WAN1)
:log info ("$inter: Actual Gateway: " . $cGateway)
:log info ("$inter: $cGateway%$inter")
:if ($oldGatewayETHER1WAN1 != $cGateway) do={
:set oldGatewayETHER1WAN1 "0.0.0.0"
/ip route {
:foreach i in=[find comment=$inter] do={
:log info ("$inter: $inter")
/ip route remove $i
}
}
/ip route add distance=1 dst-address=0.0.0.0/0 gateway=("$cGateway%$inter") routing-mark=("to_$inter") comment=$inter
/ip route add distance=1 dst-address=0.0.0.0/0 gateway=("$cGateway%$inter") comment=$inter
:set oldGatewayETHER1WAN1 $cGateway
}
:local getdate [/system clock get date]
:local gettime [/system clock get time]
:global timeETHER1WAN1 "$getdate - $gettime"