Page 1 of 1

Why Load-balancing script does’nt work ?

Posted: Mon Mar 13, 2006 7:53 pm
by eggnog
http://www.mikrotik.com/docs/ros/2.8/appex/scripting1
Load-balancing 1

According to the page , it’s easy to make a load balancing RouterOS.
After I try ten times , I never success.
I found the problem is [ :set R1 1.1.1.1] never set value 1.1.1.1 for R1 in IF statement.
I am sure the tool netwatch is work,because netwatch show the status of R1 is down when I turn off the R1 router. And the run-count of system scripts show that the script haved been runned one time.Beause [ :set R1 1.1.1.1] never give value for R1,result of gateway=($R1 . , . $R2) also isn’t correct.If you replace gateway=3.3.3.3.1,you can do /ip router print,and find the gateway was changed successful.
Can anybody can help me ? Thank you, Nick


/ip route add gateway=1.1.1.1,2.2.2.1
/system script set fo source={
:local R1
:local R2
:if ([/tool netwatch get R1 status]=up) do={:set R1 1.1.1.1}
:if ([/tool netwatch get R2 status]=up) do={:set R2 2.2.2.1}
/ip route set [/ip route find dst-address=0.0.0.0/0] \
gateway=($R1 . , . $R2)
}
/tool netwatch add comment=R1 host=1.1.1.1 interval=5s up-script=fo \
down-script=fo
/tool netwatch add comment=R2 host=2.2.2.1 interval=5s up-script=fo \
down-script=fo

Posted: Tue Mar 14, 2006 2:57 pm
by Eugene
These lines:
 :local R1
:local R2 
should be changed to the following:
 :local R1 ""
:local R2 "" 

Posted: Tue Mar 14, 2006 7:21 pm
by eggnog
These lines:
 :local R1
:local R2 
should be changed to the following:
 :local R1 ""
:local R2 "" 
Thank you ....you save my life.

Posted: Thu May 24, 2007 9:18 am
by maroon
guys i need your help in this issue,

does this example works as a failover too?

let's say grp1 works through GW1, grp2 works through GW2 (i'm taking this idea from an example on wiki.mikrotik.com) and if GW1 is down, so how can I let grp1 goes through GW2?

your help is more than highly appreciated

regards