Community discussions

MikroTik App
 
yacsap
Member Candidate
Member Candidate
Topic Author
Posts: 121
Joined: Wed Dec 17, 2014 11:44 am
Location: the land of the long white cloud
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
 
User avatar
sebastia
Forum Guru
Forum Guru
Posts: 1782
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: 1263
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]
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7042
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
Member Candidate
Member Candidate
Topic Author
Posts: 121
Joined: Wed Dec 17, 2014 11:44 am
Location: the land of the long white cloud
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?
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

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]]
 
yacsap
Member Candidate
Member Candidate
Topic Author
Posts: 121
Joined: Wed Dec 17, 2014 11:44 am
Location: the land of the long white cloud
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 👍
 
yacsap
Member Candidate
Member Candidate
Topic Author
Posts: 121
Joined: Wed Dec 17, 2014 11:44 am
Location: the land of the long white cloud
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?

Who is online

Users browsing this forum: Bing [Bot] and 14 guests