Community discussions

MikroTik App
 
ookonek
just joined
Topic Author
Posts: 9
Joined: Mon Mar 14, 2016 12:55 pm

Random select host

Mon Mar 14, 2016 1:06 pm

Hi!

I am looking for script which automatically change VPN host from list.

For example:

I have some vpn hosts:

VPNLIST=(01.vpn.host.pl 02.vpn.host.pl 03.vpn.host.pl 04.vpn.host.pl)

(in bash could be)
RANDOM=$$$(date +%s)
selectVPNLIST=${VPNLIST[$RANDOM % ${#VPNLIST[@]} ]}
echo $selectVPNLIST

..and I would random select only one host and add it to pptp-client...

/interface pptp-client add name=Somename connect-to=$selectVPNLIST ...

I don't know how to prepare script in mikrotik which automatically change vpn host every 24 hours.
Could anybody help me?
 
User avatar
patrikg
Member
Member
Posts: 372
Joined: Thu Feb 07, 2013 6:38 pm
Location: Stockholm, Sweden

Re: Random select host

Mon Mar 14, 2016 1:19 pm

Why not just use the dns with round robin ??
Make a cname with many entries.
 
ookonek
just joined
Topic Author
Posts: 9
Joined: Mon Mar 14, 2016 12:55 pm

Re: Random select host

Mon Mar 14, 2016 1:30 pm

I would make script which turn off vpn interface, select new host and add one more time interface with new hostname.

I don't think its good idea to use DNS for me.

I need "only" random function to select hostname from list. :P
 
ookonek
just joined
Topic Author
Posts: 9
Joined: Mon Mar 14, 2016 12:55 pm

Re: Random select host

Thu Mar 17, 2016 11:53 pm

Nobody hasn't any idea? Help me! :)


If I will use dns with round robin how can I do it?