mirror of
https://github.com/wifinigel/MikrotikScripting.git
synced 2025-06-22 09:43:31 +02:00
27 lines
722 B
Text
27 lines
722 B
Text
|
# ch10-10-add-remove-vlans.rsc
|
||
|
|
||
|
# a script to add and remove 50 VLANs to/from
|
||
|
# a Mikrotik router interface
|
||
|
|
||
|
: for VlanId from 200 to 249 do={
|
||
|
|
||
|
# find LAN interface ID
|
||
|
:local LanInterface "ether2";
|
||
|
:local LanInterfaceId [/interface find default-name=$LanInterface];
|
||
|
|
||
|
# add VLAN to LAN interface
|
||
|
:local VlanName "VLAN$VlanId";
|
||
|
/interface vlan add name="$VlanName" vlan-id=$VlanId \
|
||
|
interface=$LanInterfaceId;
|
||
|
}
|
||
|
|
||
|
: for VlanId from 200 to 249 do={
|
||
|
|
||
|
# find LAN interface ID
|
||
|
:local LanInterface "ether2";
|
||
|
:local LanInterfaceId [/interface find default-name=$LanInterface];
|
||
|
|
||
|
# add VLAN to LAN interface
|
||
|
:local VlanName "VLAN$VlanId";
|
||
|
/interface vlan remove "$VlanName";
|
||
|
}
|