Community discussions

MikroTik App
 
jgau4879
just joined
Topic Author
Posts: 1
Joined: Fri Jan 29, 2010 1:12 am

Remote-random option in openvpn-client

Fri Jan 29, 2010 1:15 am

How I can configure remote-random in openvpn-client mikrotik interface? I tried adding in "connect to" option the both directions of my server but only works first one.

Everyone solved this?

Thank you!

Gäux
 
zigli
just joined
Posts: 4
Joined: Wed Jul 25, 2012 8:03 am

Re: Remote-random option in openvpn-client

Thu Aug 02, 2012 12:43 pm

How I can configure remote-random in openvpn-client mikrotik interface? I tried adding in "connect to" option the both directions of my server but only works first one.

Everyone solved this?

Thank you!

Gäux
You have to use scripts:
For example:

#Generate random number (0-3)
:local p1
:local var1
:local var2
:local var3
:local var4
:set var1 ([:pick [/system clock get time] 6 8])
:set p1 ([:len [/system resource get uptime]])
:set var2 ([:pick [/system resource get uptime] ($p1-2) $p1])
:set var3 (($var1 * $var2) / 48)
:set var4 [:pick $var3 ([:len $var3]-1) [:len $var3]]
:if ($var4>3) do={:set var4 ($var4/3) }
#You can use your own

:local Remotes="1.1.1.1,2.2.2.2,3.3.3.3,4.4.4.4"
:local RemotesArray [:toarray $Remotes];
:local RemoteRandom [:pick $RemotesArray $var4];

#Detect interface id
:local intID [ /interface ovpn-client find name=tun1 ];
#Check if interface is down
:if ([/interface ovpn-client get tun1 running ] = false) do={
/interface ovpn-client set numbers=$intID disabled=yes
/interface ovpn-client set numbers=$intID connect-to=$RemoteRandom
/interface ovpn-client set numbers=$intID disabled=no
}

Who is online

Users browsing this forum: Bing [Bot], rnasci, sebi099, shampooms and 158 guests