Hi, i have 5 Hotspots right now, and i’m planning on installing about 45 more during this year.
I have Walled Garden Pages and IP Bindings that i really need to have centralized.
Is there any possibility to have all sincronized between all the hotspot devices?
It can be a .rsc file to be stored in a ftp server and then downloaded by all the hotspot devices.
The initial idea would be to use my central’s hotspot to program the Walled Garden and the IP Bindings, and have it exporting the .rsc file, and then have all the other hotspots downloading and executing the .rsc file.
If the export wouldn’t be possible, i can have the .rsc file stored in the ftp server and edit it manually, and have all the hotspots downloading and executing the .rsc file.
You really could do either. It just depends. You could even have a linux box download it… process it with perl and re-upload it. I did some custom scripting a while back to move static DNS entries from one box to another.
Are you willing to share a working script so i could accomplish that task, i would really appreciate it.
I’ve been trying to import, export and download files using mikrotik script’s, but i’m not getting the job done.
I belive that it would be easier to have a central manual file that i can edit, and then the devices can get that file a run the script to apply the changes.
But it would be really awsome to get my central system to export the necessary content and upload it to my ftp server, and the procede with the rest of the process.
You can make a script for this purpose and schedule it to all of your routers to run it daily at specific timings. via this script, all routers will pull the walled garden list from central FTP server (you can update it as you required) and then it will remove old entries, and update new one according to newly downloaded list.
Make sure you don’t add any space at the end of the line or any empty line.
Upload this data.txt to your central FTP server files section.
Now create a script on all your hotspot routers, the script will fetch a file name data.txt from your central FTP server and will parse it and add entries to your hotspot walled garden ip list. You can schedule the script to run on Daily basis.
Tested with ROS 5.20
# January 3rd, 2014
# Script Started .... Syed Jahanzaib / aacable @ hotmail . com
# Printing local time for Log purposes ...
:local CurrentTime [/system clock get time];
:log warning "Script Start to Update HOTSPOT WALLED ip garden at Current Time = $CurrentTime. . ."
# Downloading / Fetching the Walled Garden List from centgral FTP Server ...
/tool fetch url=http://yourdomain.com/files/data.txt
# Removing any Previous Entries to avoid duplication , using comments detection ...
:foreach entry in=[/ip hotspot walled-garden ip find comment=allowed-walled-garden-domains] do={
/ip hotspot walled-garden ip remove $entry
}
:if ( [/file get [/file find name=data.txt] size] > 0 ) do={
# Parsing data.txt for URLS to be added later in HS Walled Garden
:global content [/file get [/file find name=data.txt] contents] ;
:global contentLen [ :len $content ] ;
:global lineEnd 0;
:global line "";
:global lastEnd 0;
:do {
:set lineEnd [:find $content "\n" $lastEnd ] ;
:set line [:pick $content $lastEnd $lineEnd] ;
:set lastEnd ( $lineEnd + 1 ) ;
# ignore lines which have hash sign in start of line , comment out.
:if ( [:pick $line 0 1] != "#" ) do={
:local entry [:pick $line 0 ($lineEnd -1) ]
:if ( [:len $entry ] > 0 ) do={
# Adding Entries in Walled Garden IP list from the parsed data
/ip hotspot walled-garden ip add action=accept disabled=no dst-host="$entry" comment=allowed-walled-garden-domains;
}
}
} while ($lineEnd < $contentLen)
}
:log warning "Script Completed ... at Current Time = $CurrentTime . . . Jz"
# Script Completed ....
Make sure not to add any empty space or empty line. simple flat entries with no spaces.
I have tested with 5.20 several times, and working gr8.
[update: even i tested with empty spaces and it worked fine]
The script is woorking perfectly as i stated before.
It may be a problem with RouterOS V6.x, as i tested it out in a couple of devices with different RouterOS V6 versions and in all of them i had to add the 2 mentioned lines.
I don’t have any V5.x devices i can test on, but i would like to know if any other user has the chance to try it out.
As i said in the beggining, your script is already up and runnig, and it’s wonderfull, does the job as i need, and i can even use it for many other applications, like IP Binding, and many more
Hi,
i have a problem whith script.
I have router os v 6.27 and when launching the script goes in loop generating ever more rows of walled garden.
how can I avoid this loop?
any solution for lopp issue? i am using this script and its working perfect in 5.x version, but with version 6.33 its LOOPING and keep adding same hosts again n again until i stop it