I would like to get the distance of a route for scripting purpose.
something like :
if([/ip route get "distance of a route"] = 5 ) do={
:log error "distance is 5";
}
but i can't get any command that provides me a distance of a route.
:if ([/ip route get [find <your_search_criteria_goes_here>] distance] = 5) do={
...
}
This does not work.Try this:
Code: Select all:if ([/ip route get [find <your_search_criteria_goes_here>] distance] = 5) do={ ... }
:if ([/ip route get [find gateway=x.x.x.x] distance] = 3) do={
:log error "test2"
}
:if ([/ip route [find gateway=x.x.x.x] distance]=2) do={:log error “True”}
This also does not work for me.Spacing maybe!?!? This works for me:Code: Select all:if ([/ip route [find gateway=x.x.x.x] distance]=2) do={:log error “True”}
/ip route add dst-address=1.2.3.4/32 gateway=1.2.3.4 distance=5;
:if ([/ip route get [find gateway=1.2.3.4] distance]=5) do={:put "True"} else={:put "False"};
##Should have output of "True" since distance is 5;
/ip route set [find gateway=1.2.3.4] distance=6;
:if ([/ip route get [find gateway=1.2.3.4] distance]=5) do={:put "True"} else={:put "False"};
##Should have output of "False" since distance is 6;
:if ([/ip route get [find gateway=1.2.3.4] distance]=6) do={:put "True"} else={:put "False"};
##Should have output of True since IF/ELSE and distance is 6;
Indeed this works on my main Mikrotik, but not on the other one.Is x.x.x.x a unique ID or do you have multiple with gateway=x.x.x.x?
Copy and paste the following in Terminal:Code: Select all/ip route add dst-address=1.2.3.4/32 gateway=1.2.3.4 distance=5; :if ([/ip route get [find gateway=1.2.3.4] distance]=5) do={:put "True"} else={:put "False"}; ##Should have output of "True" since distance is 5; /ip route set [find gateway=1.2.3.4] distance=6; :if ([/ip route get [find gateway=1.2.3.4] distance]=5) do={:put "True"} else={:put "False"}; ##Should have output of "False" since distance is 6; :if ([/ip route get [find gateway=1.2.3.4] distance]=6) do={:put "True"} else={:put "False"}; ##Should have output of True since IF/ELSE and distance is 6;