# # SO WIFI script for Mikrotik RouterOS v 1.3 # # First add a new 'Mikrotik' device under 'Devices' and use the location id seen there to replace the one below. # Add this script under Scripts in Winbox and run it once. # Then go to Bridge->Ports and add the (wired or wireless) port you wish to use to the bridge 'bridge-socialwifi' :global locationid "00000"; # change this ^^^^^^^^^^^^^^^^^^ #/ip hotspot reset-html 0 # REMOVE EXISTING CONFIG FOR SOCIAL WIFI :global hotspotname "socialwifi-$locationid" /ip hotspot remove [/ip hotspot find where name=$hotspotname] /ip pool remove [/ip pool find where name="hs-pool-socialwifi"] /ip dhcp-server remove [/ip dhcp-server find where name="dhcp-socialwifi"] /ip hotspot user remove [/ip hotspot user find where name="user"] /ip hotspot profile remove [/ip hotspot profile find where name="hsprof-socialwifi"] /ip addres remove [/ip address find where interface=bridge-socialwifi] /ip dhcp-server network remove [/ip dhcp-server network find where comment="hotspot network"] /interface bridge remove [/interface bridge find where name="bridge-socialwifi"] :global model [/system routerboard get model] :global modelUrlEncoded "" :for i from=0 to=([:len $model] - 1) do={ :local char [:pick $model $i] :if ($char = " ") do={ :set $char "%20" } :if ($char = "-") do={ :set $char "%2D" } :set modelUrlEncoded ($modelUrlEncoded . $char) } :put $modelUrlEncoded :global mac [/system routerboard get serial-number] :global fw [/system routerboard get current-firmware] :global fwt [/system routerboard get firmware-type] :global path "hotspot"; :if ([:len [/file find name=flash/hotspot/login.html]] > 0) do={ :set path "flash/hotspot" } /interface bridge add name=bridge-socialwifi /ip hotspot profile add hotspot-address=10.1.0.1 html-directory=$path login-by=mac,http-pap mac-auth-mode=mac-as-username-and-password name=hsprof-socialwifi radius-interim-update=10m radius-mac-format=XX-XX-XX-XX-XX-XX use-radius=yes /ip hotspot user profile set [ find default=yes ] shared-users=unlimited /ip pool add name=hs-pool-socialwifi ranges=10.1.0.2-10.1.7.254 /ip dhcp-server add address-pool=hs-pool-socialwifi disabled=no interface=bridge-socialwifi lease-time=1h name=dhcp-socialwifi /ip hotspot add address-pool=hs-pool-socialwifi addresses-per-mac=1 disabled=no interface=bridge-socialwifi name="socialwifi-$locationid" profile=hsprof-socialwifi /ip address add address=10.1.0.1/21 comment="hotspot network" interface=bridge-socialwifi network=10.1.0.0 /ip dhcp-server network add address=10.1.0.0/21 comment="hotspot network" gateway=10.1.0.1 /ip firewall nat add action=masquerade chain=srcnat comment="masquerade hotspot network" src-address=10.1.0.0/21 /ip hotspot user add name=user /ip hotspot walled-garden remove [find where dst-host="hotspots.so-wifi.com"];add dst-host=hotspots.so-wifi.com remove [find where dst-host="*.facebook.com"];add dst-host=*.facebook.com remove [find where dst-host="*.facebook.net"];add dst-host=*.facebook.net remove [find where dst-host="*.fbcdn.net"];add dst-host=*.fbcdn.net remove [find where dst-host="*.akamaihd.net"];add dst-host=*.akamaihd.net remove [find where dst-host="*.cloudfront.net"];add dst-host=*.cloudfront.net remove [find where dst-host="ssl.google-analytics.com"];add dst-host=ssl.google-analytics.com /radius remove [find where address=87.233.181.54];add address=87.233.181.54 secret=sowifihotspots service=hotspot remove [find where address=87.233.181.55];add address=87.233.181.55 secret=sowifihotspots service=hotspot /file set "$path/login.html" contents="" /file set "$path/alogin.html" contents="\$(if http-status == 302)Hotspot login required\$(endif)\$(if http-header == \"Location\")\$(link-redirect)\$(endif)" /system scheduler remove [ /system scheduler find where name=SocialwifiCheckin] add comment="Run social wifi checkin" disabled=no interval=30m name=SocialwifiCheckin on-event="/tool fetch url=\"https://hotspots.so-wifi.com/admin/mikrotik/checkin/id/$locationid\?model=$modelUrlEncoded&mac=$mac&firmware=$fw&firmware-type=$fwt\" mode=\"https\" dst-path=\"mikrotik-config.rsc\";/delay 2;/import mikrotik-config.rsc;/file remove mikrotik-config.rsc"} policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive start-date=Nov/14/2012 start-time=01:00:00