Community discussions

 
Byxxi
just joined
Topic Author
Posts: 3
Joined: Wed Aug 14, 2019 1:48 pm

mAP lite as travel router

Wed Aug 14, 2019 2:13 pm

Hi,

I'm trying to create a script for my mAP lite, so that it's easier to bring on my travels to different locations. I want a script that runs at startup, which scans all available networks in the area and matches them to my known networks(security profiles). If it finds a known network, set up the wireless station with the correct SSID and security profile. If it does not find a match, set up the master interface as an AP.

At the moment I've only managed to wireless in the area at startup. I'm not sure how to compare what I've found to any known networks.
Current script:

Code: Select all

#wait 15s after startup for wireless to be up
:delay 15;
#background scan wlan1 for 15 sec, save to scan.txt
:interface wireless scan duration=15 wlan1 background=yes save-file=scan.txt;
:log info "wireless scan complete";

#Put content of scan.txt into ScanContents variable:
:global ScanContents [/file get scan.txt contents];
I've created a regular expression to capture the SSIDs from the wireless scan.

Code: Select all

'(.+)'

At the moment I haven't found out how to use this for something useful.

Am I on the right path, is there a better way to do this?

I'm still pretty new to the mikrotik-world, so I appreciate all the help I can get!
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1290
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

Re: mAP lite as travel router

Wed Aug 14, 2019 4:07 pm

Interesting question. Will have a look at it when I am back from holiday.
 
How to use Splunk to monitor your MikroTik Router

MikroTik->Splunk
 
 
nescafe2002
Long time Member
Long time Member
Posts: 617
Joined: Tue Aug 11, 2015 12:46 pm
Location: Netherlands

Re: mAP lite as travel router

Wed Aug 14, 2019 4:52 pm

You may want to use the built in profile feature to connect to any known network in the list.

/interface wireless
set [ find default-name=wlan1 ] default-authentication=no disabled=no ssid=""
/interface wireless security-profiles
add authentication-types=wpa2-psk mode=dynamic-keys name=profile1 wpa2-pre-shared-key=KEY1
add authentication-types=wpa2-psk mode=dynamic-keys name=profile2 wpa2-pre-shared-key=KEY2
/interface wireless connect-list
add interface=wlan1 security-profile=profile1 ssid=SSID1
add interface=wlan1 security-profile=profile2 ssid=SSID2

See also: https://wiki.mikrotik.com/wiki/Manual:I ... nnect_List


To run AP & Client simultaneously, you can run AP as master and station as virtual interface (use wlan2 in connect-list entries).

/interface wireless
set [ find default-name=wlan1 ] disabled=no mode=ap-bridge ssid=AP1
add default-authentication=no disabled=no master-interface=wlan1 mode=station name=wlan2 ssid=""

The hardest part is to enable/disable wlan1 AP based on succesful connection of wlan2 station.
One solution would be to set hide-ssd of wlan1 based on running status of interface wlan2 using scheduler.
 
nostromog
Member Candidate
Member Candidate
Posts: 149
Joined: Wed Jul 18, 2018 3:39 pm

Re: mAP lite as travel router

Wed Aug 14, 2019 5:12 pm

(...)

To run AP & Client simultaneously, you can run AP as master and station as virtual interface (use wlan2 in connect-list entries).

/interface wireless
set [ find default-name=wlan1 ] disabled=no mode=ap-bridge ssid=AP1
add default-authentication=no disabled=no master-interface=wlan1 mode=station name=wlan2 ssid=""

The hardest part is to enable/disable wlan1 AP based on succesful connection of wlan2 station.
One solution would be to set hide-ssd of wlan1 based on running status of interface wlan2 using scheduler.
This was not working for me when I tried. When the station is the primary interface, it will follow the AP and connect in whatever channel, but when the AP is the primary interface, it will stay in whatever channel it is set, not following the AP (or even finding it if it is not by chance).

So basically having the master interface as station is the only operative way.
 
Byxxi
just joined
Topic Author
Posts: 3
Joined: Wed Aug 14, 2019 1:48 pm

Re: mAP lite as travel router

Wed Aug 14, 2019 5:15 pm

The wireless connect list was something I was unaware of. That looks very interesting, I will look more into that.

The reason for wanting the master interface to be the station is that it allows me to have the frequency set to auto. Problems arise when the station can't connect to anything, because the virtual interfaces, AP in this case won't activate until the master is active.
 
Byxxi
just joined
Topic Author
Posts: 3
Joined: Wed Aug 14, 2019 1:48 pm

Re: mAP lite as travel router  [SOLVED]

Fri Aug 16, 2019 4:48 pm

I've experimented a bit more. Made a script that I think can do the trick.
#wait 3s after startup to run script
:delay 3

#ensure that master wireless is set as station
/interface wireless set client mode=station ssid="" security-profile=default;
:log info "Set client network as station";

#wait 15s for wireless to have time to connect
:delay 15;

#check if wireless is connected to a network
local connectstatus [/interface get client running]

#if wireless is connected to something, don't do anything. Else set master wireless as AP
if $connectstatus do={
:log info "Network active, keep on keeping on";
} else={
/interface wireless set client mode=ap-bridge ssid="MikroTik" security-profile=AP;
:log info "Network not active, setting master network to AP";}
In addition to that script, I've made use of the connect list so that the router knows which networks to connect to, and which security profile to use.
/interface wireless connect-list
add interface=client security-profile=network name ssid=network name
Let me know if there is something that I haven't though about, or if something can be improved upon. I'll marked this as solved if no one comes up with anything after a while.

Who is online

Users browsing this forum: Google [Bot] and 5 guests