I’m trying to script a Mikrotik radio to be able to connect to multiple SSID-PSK pairs, just like a regular laptop will do.
I’ve created an array of SSID-PSK
But then I’m stuck, I don’t really know if I need to create several /wireless virtual entries for the wireless interface?
One virtual per Security profile ?
Bridge them all ?
Will the radio scan between them all and connect to the first SSID ?
If it sees 2 AP with known SSID-PSK, will it oscillate between both or will it wait until one drops before switching AP?
# --- Place your SSID=PSK pairs in the WlanSSIDPSK Array below
:global WlanSSIDPSK {"Corporate"="Verrry Secret" ; "Guest"="Not Too Secret" ; "Office"="Secret" }
#-- Saving the PSK Wifi passwords
/interface wireless security-profiles
:foreach SSID,PSK in=$WlanSSIDPSK do={
add name=$SSID mode=dynamic-keys authentication-types=wpa-psk,wpa2-psk wpa-pre-shared-key=$PSK wpa2-pre-shared-key=$PSK
}
#-- Linking the security profiles to the available SSIDs. Make sure that the wireless is not tied to any particular ssid
/interface wireless set 0 ssid=""
/interface wireless connect-list
:foreach SSID,PSK in=$WlanSSIDPSK do={
add interface=wlan1 connect=yes ssid=$SSID security-profile=$SSID
}
Yes I could combine both :foreach loops into a single one, but I find it clearer and easier to maintain this way.
I hope this is useful to others.
Kind Regards, Martin Politick October 2017.