Community discussions

MikroTik App
just joined
Topic Author
Posts: 3
Joined: Sun Nov 20, 2011 11:21 pm

How to get value if route is enabled?

Mon Nov 21, 2011 12:57 am

Hello, I tried this route check script, but of course it is not working :)
Can somebody point me in right direction?

Here is what i wrote:
:if (([/ip route find comment=natlut]=enabled)&&( [/ip route find comment=KDS]=enabled)) do={
    /ip route enable [/ip route find comment=prhinasve];
} else={
    /ip route disable [/ip route find comment=prhinasve];
Forum Guru
Forum Guru
Posts: 7734
Joined: Tue Aug 11, 2009 3:19 am

Re: How to get value if route is enabled?

Mon Nov 21, 2011 2:00 am

First of all, there's no "enabled" for routes - there is !disabled, though. Secondly, you can't compare to that either. You have to find the routes by attributes and then check if anything is returned.

This should work:
:if (([:len [/ip route find where comment="natlut" and !disabled]] > 0) and ([:len [/ip route find where comment="KDS" and !disabled]] > 0)) do={
	/ip route { enable [find comment="prhinasve"]};
} else={
	/ip route { disable [find comment="prhinasve"]};	
However that doesn't seem like something you'd normally want to do. Maybe you could solve this by using recursive routes instead? What are you trying to achieve?
Specific answers require specific questions. When in doubt, post the output of "/ip address print detail", "/ip route print detail", "/interface print detail", "/ip firewall export", and an accurate network diagram.

Who is online

Users browsing this forum: No registered users and 17 guests