Community discussions

MikroTik App
 
ashpri
Member Candidate
Member Candidate
Topic Author
Posts: 154
Joined: Sun Oct 14, 2018 3:11 am

How to use the find command

Wed Sep 07, 2022 3:41 am

Let's say I have the folllowing setup:

/interface bridge vlan
add bridge=bridge1 tagged=bridge1,wlan2.0,ether1,ether2,ether3,ether4,ether5 vlan-ids=3
add bridge=bridge1 tagged=wlan2.0,ether1,ether2,ether3,ether4,ether5 vlan-ids=20
add bridge=bridge1 tagged=wlan2.0 vlan-ids=25
add bridge=bridge1 tagged=wlan2.0 vlan-ids=30
...
add bridge=bridge1 tagged=wlan2.0 vlan-ids=50

----

I would like to add tagged=eth1,2,3,4,5 to vlan-ids=25 to 50 (rather than manually one by one adding via gui)

How would I use the find command to do this. I tried the following without success:

/interface bridge vlan
[find vlan-ids=25] set tagged=ether1,ether2,ether3,ether4,ether5
 
AidanAus
Member Candidate
Member Candidate
Posts: 177
Joined: Wed May 08, 2019 7:35 am
Location: Australia
Contact:

Re: How to use the find command

Wed Sep 07, 2022 6:13 am

local count (number here at the vlan you want to start at)
foreach i in=[interface bridge vlan find] do={ local vn [interface bridge vlan find vlan-ids=$count] ; interface bridge vlan set numbers=$vn tagged=ether1,ether2,ether3,ether4,ether5; if ($count<=10) do=[set count ($count + 1)] }


Take a look over that, check the bolds as that is what you need to edit, the count variable will be the starting vlan number and at the end where it adds 1 to count to increment it each time it runs the loop, you can control the higher vlan number to stop at.
script could be better but it works so that's a bonus :)

edited to take the code out of the code block as it removes the word formatting :)
 
User avatar
nichky
Forum Guru
Forum Guru
Posts: 1280
Joined: Tue Jun 23, 2015 2:35 pm

Re: How to use the find command

Wed Sep 07, 2022 6:17 am

is that what u want?

[admin@R1] /interface bridge vlan> edit number=x value-name=vlan-ids

once u change ctrl+o to save it
 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 11587
Joined: Thu Mar 03, 2016 10:23 pm

Re: How to use the find command

Wed Sep 07, 2022 7:04 am

I've corrected command for you:
/interface bridge vlan
set [find vlan-ids=25] tagged=ether1,ether2,ether3,ether4,ether5
 
ashpri
Member Candidate
Member Candidate
Topic Author
Posts: 154
Joined: Sun Oct 14, 2018 3:11 am

Re: How to use the find command

Wed Sep 07, 2022 8:45 am

Thank you for the various solutions. I am in the process of learning scripting so the script solution is a great start.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12001
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: How to use the find command  [SOLVED]

Wed Sep 07, 2022 3:59 pm

...(from) 25 to 50...
mmm....
/interface bridge vlan
set [find where vlan-ids~"(2[5-9]|[3-4][0-9]|50)"] tagged=ether1,ether2,ether3,ether4,ether5
 
joshhboss
Member Candidate
Member Candidate
Posts: 273
Joined: Thu Aug 01, 2019 2:13 pm

Re: How to use the find command

Mon Oct 02, 2023 11:14 pm

...(from) 25 to 50...
mmm....
/interface bridge vlan
set [find where vlan-ids~"(2[5-9]|[3-4][0-9]|50)"] tagged=ether1,ether2,ether3,ether4,ether5
Could you break that down.. im trying to do the similar thing where I have vlans on numbers
35 X bridge 400
36 X bridge 401
37 X bridge 600
38 X bridge 601

and id like to tagged them all to lets say "combo2" for instance.

I didnt get how the find where vlan-ids~"(2[5-9]|[3-4][0-9]|50)" translates to 25-50
 
joshhboss
Member Candidate
Member Candidate
Posts: 273
Joined: Thu Aug 01, 2019 2:13 pm

Re: How to use the find command

Tue Oct 03, 2023 1:26 am

Ok I think I got it.. GPT helped out..


Absolutely, let me break it down for you!

/interface bridge vlan: This is the command that tells the router you're working with VLAN settings in the context of a bridge interface.
set: This is a command used to modify or set parameters. In this case, you're about to modify some parameters related to VLANs.
[find where vlan-ids~"(2[5-9]|[3-4][0-9]|50)"]: This part is a filter. It selects the VLANs based on their IDs. The IDs selected are in the range 25 to 50. The syntax 2[5-9] means any number starting with 2 followed by a digit from 5 to 9, [3-4][0-9] means any number starting with 3 or 4 followed by any digit, and 50 is just 50.
tagged=ether1,ether2,ether3,ether4,ether5: This part sets the tagged interfaces for the selected VLANs. It means that traffic belonging to these VLANs will be tagged when transmitted on the specified Ethernet interfaces (ether1, ether2, ether3, ether4, and ether5).

Who is online

Users browsing this forum: Grumpy and 54 guests