Community discussions

MikroTik App
 
nostromog
Member Candidate
Member Candidate
Topic Author
Posts: 226
Joined: Wed Jul 18, 2018 3:39 pm

Detecting wireless roaming

Wed May 01, 2019 9:38 pm

Hi, I have a problem with a travel router relative to station mode and connect lists

I set up a mAP Lite to connect as a station to different wifi APs using a connect list, and bridged it with a virtual AP.
/interface wireless security-profiles
set [ find default=yes ] group-ciphers="" supplicant-identity=TR unicast-ciphers=""
add authentication-types=wpa2-psk mode=dynamic-keys name=SP1 supplicant-identity=TR ...
add authentication-types=wpa2-psk mode=dynamic-keys name=SPAnd supplicant-identity=TR
add authentication-types=wpa2-psk group-ciphers=tkip,aes-ccm mode=dynamic-keys name=SP3 supplicant-identity=TR \
    unicast-ciphers=tkip,aes-ccm
add authentication-types=wpa2-eap eap-methods=peap mschapv2-username=user1 name=SP4 supplicant-identity=\
    id1
    ...
/interface wireless connect-list
  add interface=sta1 security-profile=SP1 ssid=AP1 comment="Office1"
  add interface=sta1 security-profile=SP1 ssid=AP2 comment="Office2"
  add interface=sta1 security-profile=SPAnd ssid=MyAndroid comment="My corporate cellular"
  add interface=sta1 security-profile=SP3 ssid=AP3 comment="Cafe 1"
  add interface=sta1 security-profile=SP4 ssid=AP4 comment="Corp 1"
 ...
The setting works quite well: when I start my mAP somewhere it connects to the priority one available, and when I
move to a different place or start my cellular phone tethering it roams to it.

The problem I'm seeing for this approach is that when I move with the mAP Lite from one place to another the dhcp-client
does not notice at all. This brings two kind of problems:
  • Some APs blacklist the router when it "speaks" in the wrong network or sends DHCP messages with the wrong network
  • Even in those not blacklisting me, I get no connection until the lease expires or I manually release it. My phone AP has a lease of 1 hour, and some of the others 24h.
I wonder if there is an efficient way to detect in a script the media change and release the DHCP lease.
 
nostromog
Member Candidate
Member Candidate
Topic Author
Posts: 226
Joined: Wed Jul 18, 2018 3:39 pm

Re: Detecting wireless roaming

Sun May 05, 2019 6:00 pm

A tentative solution, the best I could come with:
# ensure that registration/dhcp lease are current...
do {
   :local GatewayIP  [/ip dhcp-client get [find interface="wan-bridge"] gateway ]
   :local GatewayMac [/ip arp get [find address=$GatewayIP] mac-address ]
   :if (([:len [/interface bridge host find mac-address=$GatewayMac]]=0) or \
       ([/interface bridge host get [find mac-address=$GatewayMac] age ]>5s)) \
        do={
          /log info "releasing dhcp lease on network change"
          /ip dhcp-client release [find where interface="wan-bridge"]
          /ipv6 dhcp-client release [find where interface="wan-bridge"]
          }
   } on-error={ /log info "error checking DHCP validtity"}

:put "$GatewayIP $GatewayMac $[/interface bridge host get [f where mac-address=$GatewayMac] age]"}
I tried this using /ip dhcp-client get [find interface="wan-bridge"] dhcp-server], but I found a number of hotspots where the dhcp-server was a different host to
the gateway, and not accessed, so checking its availability was hard (its age was usually high). I tested the age of the port in the bridge as an indicative of a stale
gateway.

With this value I could land in a place where the $GatewayIP is the same, and sit on a broken lease for
some time, but I can't find a way to solve it, as wireless roaming happens in layer 2, while DHCP happens in layer 3 (more like 2.5) and there is no clean record of MAC in the dhcp-client information.

Also, there is no clear trigger to run a script after roaming happens, as it should only happen when I roam to a different hotspot...

Any idea?

Who is online

Users browsing this forum: abbio90 and 36 guests