Community discussions

MikroTik App
 
metaltuman
just joined
Topic Author
Posts: 12
Joined: Sun Dec 25, 2011 3:27 am

Script for disabling wlan

Sun Aug 12, 2012 8:27 pm

I need a script that would track the records in the ARP table on the client access point, and if there is no records relating to the LAN port of SXT disabling wireless interface (on client sxt) and enable it back when a record appear.

ARP is dynamic, without any filters.
I want to track records that contains IP`s 192.168.1.*

Omnitik configured as router (wan - ether1 (dhcp), lan - wlan1 (192.168.0.1/24))
SXT`s configured as routers to (wan - wlan1(192.168.0.2/24, lan - ether1(192.168.1.1/24))

if the client turns on the computer once a day for two hours then the wlan1 on his SXT should work the same time.

Image

Thanks for your ideas.
 
metaltuman
just joined
Topic Author
Posts: 12
Joined: Sun Dec 25, 2011 3:27 am

Re: Script for disabling wlan

Fri Aug 17, 2012 11:56 am

Anyone?
 
vk7zms
Member Candidate
Member Candidate
Posts: 227
Joined: Thu Jun 29, 2006 3:01 am
Location: Hobart, Tasmania
Contact:

Script for disabling wlan

Fri Aug 17, 2012 4:49 pm

If the omnitik is handing out dhcp, there is no way for the client pc to have an IP address prior to SXT WLAN being enabled, therefore nothing in the arp table. Would be easy enough to do if client pc had static address or a second deco server was set up on the SXT
 
metaltuman
just joined
Topic Author
Posts: 12
Joined: Sun Dec 25, 2011 3:27 am

Re: Script for disabling wlan

Fri Aug 17, 2012 5:05 pm

I need to analyze ARP table on client SXT, that configured as router and provide dhcp for users behind LAN port.
If are no clients behind lan (arp table dont consist of IP`s 192.168.1.*) SXT must to disable wlan1 interface.
The script will run on SXT.
 
psamsig
Member Candidate
Member Candidate
Posts: 161
Joined: Sun Dec 06, 2009 1:36 pm
Location: Denmark

Re: Script for disabling wlan

Sat Aug 18, 2012 2:13 pm

Here is something that may get you going, I would suggest it being scheduled to run evey 5-10 seconds.
/interface {
    :local arps [:len [/ip arp find interface=ether1]]
    :local wlan [find name=wlan1]
    :local state [get $wlan disabled]
    :if ($state = true && aprs > 0) do={
        set $wlan disabled=false
    } else={
        :if ($state = false && aprs = 0) do={
            set $wlan disabled=true
        }
    }
}
 
metaltuman
just joined
Topic Author
Posts: 12
Joined: Sun Dec 25, 2011 3:27 am

Re: Script for disabling wlan

Sat Aug 18, 2012 6:40 pm

Thank you.
According to the script, that's exactly what I was looking for, but for some reason does not work.

Tested on rb751 and SXT. ROS v5.20
 
psamsig
Member Candidate
Member Candidate
Posts: 161
Joined: Sun Dec 06, 2009 1:36 pm
Location: Denmark

Re: Script for disabling wlan

Sat Aug 18, 2012 7:02 pm

Well, I was to lazy to test it, this is tested and should work:
/interface {
    :local arps [:len [/ip arp find interface=ether1]]
    :local wlan [find name=wlan1]
    :local inact [get $wlan disabled]
    :if ($inact = true && $arps > 0) do={
        set $wlan disabled=no
    } else={
        :if ($inact = false && $arps = 0) do={
            set $wlan disabled=yes
        }
    }
}
 
metaltuman
just joined
Topic Author
Posts: 12
Joined: Sun Dec 25, 2011 3:27 am

Re: Script for disabling wlan

Sat Aug 18, 2012 7:10 pm

Excellent, it works. Thank you very much.
I think this script will help relieve some of the base stations.

Who is online

Users browsing this forum: No registered users and 85 guests