How to use the find command

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

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 :slight_smile:

edited to take the code out of the code block as it removes the word formatting :slight_smile:

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

I’ve corrected command for you:

Thank you for the various solutions. I am in the process of learning scripting so the script solution is a great start.

…(> 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

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).