Willkommen bei bytebang » The blog about all and nothing » Turn Mikrotik CAP interfaces on and off by script

Turn Mikrotik CAP interfaces on and off by script

Apr 29 2019

The Problem

I am running a big Mikrotik based WiFi installation where the Guest-Wifi should not always be accessible. One way how to do this is, is to create sub interfaces and to turn them on and of at the controller as you need them.

CAPsMAN.png

In the image above, we see some of the interfaces which are managed by CAPsMAN. The gues wifi is bound to the interfaces ending with the suffix _gast

The manual way how to turn on and off the guest wifi is to enable and disable all corresponding interfaces. If you are running a larger network, then this can be a tedious task.

The Solution

Mikrotik devices are capable of running scripts. So all I needed was to write a script which iterates over all CAPsMAN managed interfaces and en/disables them.

This script enables all interfaces ending with _gast

/caps-man interface
:foreach ap in=[find where name~"gast"] do={
:put [get $ap name];
/caps-man interface enable [get $ap name];
}

This script disables all interfaces ending with_gast

/caps-man interface
:foreach ap in=[find where name~"gast"] do={
:put [get $ap name];
/caps-man interface disable [get $ap name];
}

Thats it!

Get Social


(c) 2019, by bytebang e.U. - Impressum - Datenschutz / Nutzungsbedingungen
-