Community discussions

 
yacsap
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 97
Joined: Wed Dec 17, 2014 11:44 am
Location: Auckland, New Zealand
Contact:

mass-enable all of my vlan using script

Mon Jul 29, 2019 1:50 am

Hi guys,

I'm trying to mass-enable all of my vlan using a script.

Can anyone give me an idea here:

/interface vlan> print
Flags: X - disabled, R - running
# NAME MTU ARP VLAN-ID INTERFACE
0 R vlan15-A 1500 enabled 15 bridge1-DIST
1 R vlan25-B 1500 enabled 25 bridge1-DIST
2 R vlan26-C 1500 enabled 26 bridge1-DIST
3 R vlan27-D 1500 enabled 27 bridge1-DIST
4 R vlan28-E 1500 enabled 28 bridge1-DIST
5 R vlan29-F 1500 enabled 29 bridge1-DIST
6 R vlan32-G 1500 enabled 32 bridge1-DIST
7 R vlan36-H 1500 enabled 36 bridge1-DIST
I'm thinking something like: /interface vlan> set [ find name=vlan*

Any help would be appreciated. Cheers
[ IMikroTik ] >
 
User avatar
sebastia
Forum Guru
Forum Guru
Posts: 1775
Joined: Tue Oct 12, 2010 3:23 am
Location: Antwerp, BE

Re: mass-enable all of my vlan using script

Mon Jul 29, 2019 2:38 am

Hey

I would do a loop with "foreach" over all entries of a list given by find.

:local vlans [/interface vlan find interface=<interface> ];
:foreach vl in=vlans do={
# do some magic
};

See also https://wiki.mikrotik.com/wiki/Manual:Scripting
 
savage
Forum Guru
Forum Guru
Posts: 1196
Joined: Mon Oct 18, 2004 12:07 am
Location: Cape Town, South Africa
Contact:

Re: mass-enable all of my vlan using script

Mon Jul 29, 2019 10:37 am

/interface vlan [ /interface vlan find ] set disabled=[no|yes]
Regards,
Chris
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 5921
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: mass-enable all of my vlan using script

Mon Jul 29, 2019 10:38 am

/interface vlan enable [find]
 
yacsap
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 97
Joined: Wed Dec 17, 2014 11:44 am
Location: Auckland, New Zealand
Contact:

Re: mass-enable all of my vlan using script

Mon Aug 26, 2019 4:53 am

/interface vlan enable [find]
Thanks for this, but how can I make except VLAN 10?
[ IMikroTik ] >
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1296
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

Re: mass-enable all of my vlan using script

Mon Aug 26, 2019 8:01 am

:put [/interface vlan enable [find where vlan-id!=10]]
 
How to use Splunk to monitor your MikroTik Router

MikroTik->Splunk
 
 
yacsap
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 97
Joined: Wed Dec 17, 2014 11:44 am
Location: Auckland, New Zealand
Contact:

Re: mass-enable all of my vlan using script

Wed Aug 28, 2019 12:07 am

:put [/interface vlan enable [find where vlan-id!=10]]
Hi Jotne, thanks for this 👍
[ IMikroTik ] >
 
yacsap
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 97
Joined: Wed Dec 17, 2014 11:44 am
Location: Auckland, New Zealand
Contact:

Re: mass-enable all of my vlan using script

Tue Sep 03, 2019 5:11 am

Still related with this vlan, how can I mass-disable/mass-enable the VLAN's IP?
[ IMikroTik ] >

Who is online

Users browsing this forum: No registered users and 8 guests