Hello.
I'm trying to get on via DHCP default route with comment and with dynamic gateway and make another route (eg to 1 IP of yandex only from GW of ISP-1 (ISP-1 is main internet and i have ISP-2 as reserved....
whats wrong with script of DHCPClient?Thats code is works well, but without adding additional route with a comment, but
Thats script doesnt work at all
Thats only adds default route with ISP-1 comment
I'm trying to get on via DHCP default route with comment and with dynamic gateway and make another route (eg to 1 IP of yandex only from GW of ISP-1 (ISP-1 is main internet and i have ISP-2 as reserved....
whats wrong with script of DHCPClient?
Code:
{:local rmark "ISP-1":local count [/ip route print count-only where comment="ISP-1"]:if ($bound=1) do={:if ($count = 0) do={/ip route add gateway=$"gateway-address" comment="ISP-1" distance=1} else={:if ($count = 1) do={:local test [/ip route find where comment="ISP-1"]:if ([/ip route get $test gateway] != $"gateway-address") do={/ip route set $test gateway=$"gateway-address"}} else={:error "Multiple routes found"}}} else={/ip route remove [find comment="ISP-1"]}}
Code:
{:local rmark "ISP-1":local count [/ip route print count-only where comment="ISP-1"]:if ($bound=1) do={:if ($count = 0) do={/ip route add gateway=$"gateway-address" comment="ISP-1" distance=1} else={:if ($count = 1) do={:local test [/ip route find where comment="ISP-1"]:if ([/ip route get $test gateway] != $"gateway-address") do={/ip route set $test gateway=$"gateway-address"}} else={:error "Multiple routes found"}}} else={/ip route remove [find comment="ISP-1"]}:local rmark "YANDEX":local count2 [/ip route print count-only where comment="YNDX_CHK"]:if ($bound=1) do={:if ($count2 = 0) do={/ip route add comment=YNDX_CHK distance=1 dst-address=77.88.55.242/32 gateway=$"gateway-address"} else={:if ($count2 = 1) do={:local pingchk [/ip route find where comment="YNDX_CHK""]:if ([/ip route get $pingchk gateway] != $"gateway-address") do={/ip route set $pingchk gateway=$"gateway-address"}} else={:error "Multiple YANDX check routes found"}}} else={/ip route remove [find comment="YNDX_CHK"]}}
Thats only adds default route with ISP-1 comment
Code:
{:local rmark "ISP-1":local count [/ip route print count-only where comment="ISP-1"]:local count2 [/ip route print count-only where comment="YNDX_CHK"]:if ($bound=1) do={:if ($count = 0) do={/ip route add gateway=$"gateway-address" comment="ISP-1" distance=1} else={:if ($count = 1) do={:local test [/ip route find where comment="ISP-1"]:if ([/ip route get $test gateway] != $"gateway-address") do={/ip route set $test gateway=$"gateway-address"}} else={:error "Multiple routes found"}}:if ($count2 = 0) do={/ip route add comment=YNDX_CHK distance=1 dst-address=77.88.55.242/32 gateway=$"gateway-address"} else={:if ($count2 = 1) do={:local yndxping [/ip route find where comment="YNDX_CHK"]:if ([/ip route get $yndxping gateway] != $"gateway-address") do={/ip route set $yndxping gateway=$"gateway-address"}} else={:error "Multiple Yandex check found"}}} else={/ip route remove [find comment="ISP-1"]/ip route remove [find comment="YNDX_CHK"]}}
Statistics: Posted by Foxeh — Tue Feb 20, 2024 12:32 pm