ROS switch-mode CLI commands?

I’ve tried a couple MikroTik CRS devices over the years as I want to love them, but I keep getting poked in the eye by the clunkiness of the RouterOS CLI for configuring them. Let me illustrate. Let’s say I want to use port 24 like a trunk having VLANs 10, 20 and 30 tagged on it. I already have those VLANs configured in the switch having various untagged and tagged ports, something like this:


/interface bridge vlan
add bridge=bridge comment=VLAN10 tagged=ether1,ether8 untagged=ether2,ether3,ether4,ether10 vlan-ids=10
add bridge=bridge comment=VLAN20 tagged=ether1,ether8 untagged=ether5,ether6,ether7,ether11,ether20 vlan-ids=20
add bridge=bridge comment=VLAN30 tagged=ether1,ether8,ether14 untagged=ether12,ether15,ether16 vlan-ids=30

Now, I want to tag all those VLANs on port 24. Currently, I have no way to do that from the CLI without performing all of these steps:


  1. Run /interface bridge vlan export to see where things are currently tagged
  2. Copy that output to a text editor
  3. Edit the commands in the text editor
  4. Remove the VLANs completely from the MikroTik using a command like /interface bridge vlan remove [/interface bridge vlan find where vlan-ids=10]. This creates downtime, BTW.
  5. Re-add them by copying from my modified commands in the text editor

This is VERY painful!

EDIT: I realize there is a mildly better flow using /interface bridge vlan edit [/interface bridge vlan find where vlan-ids=10] value-name=tagged for each VLAN, but this is still very clunky and no auto-completion available!

What I really want to do is just run a similar command you would on a Cisco or HP switch like this:


[switch-mode] interface 24 tagged vlan 10,20,30

This would not overwrite all VLANs currently tagged on that port, but instead add any missing ones. To remove a VLAN from that port you’d run something like this:


[switch-mode] no interface 24 tagged vlan 10

I’m not trying to say exactly what the syntax should be, but I’m trying to highlight that RouterOS needs something I’m calling a switch-mode CLI that you can jump into to enter commands in this style. These switch mode commands would not require knowledge of the current config in order to make modifications. Does something like this already exist that I just don’t know about?

Currently exists a way of doing steps 2-5 in single command without down time. Step #1 still needs to be done to make sure the following command does not break existing config:

/interface bridge vlan
set [ find bridge=bridge vlan-ids=10 ] tagged=ether1,ether8,ether24

With set command one sets individual properties, but in full (so it’s not possible to add ether24 to the list of tagged members of certain VLAN, one has to set the whole list).

/interface bridge vlan set [/interface bridge vlan find where vlan-ids=10] tagged=...
/interface bridge vlan set [/interface bridge vlan find where vlan-ids=11] tagged=... untagged=...
/interface bridge vlan set [/interface bridge vlan find where vlan-ids=12] untagged=...

The find command returns numbers list for the set command.

Thanks @mkx and @ConradPino for pointing me to the set command for this. That is a significant improvement over the methods I suggested. I’ll definitely start using that for now.

However, the fact that you must know the current config in order to change it is a severe limitation and a scenario that I believe needs improved. Even with the set command, the method to add the three VLANs to ether24 requires a lot of unnecessary work and is more prone to mistakes. Assuming we’re already at /interface bridge vlan, it’d look like this:


  1. export
  2. Copy or reference currently tagged interfaces for VLAN 10
  3. Execute set [ find bridge=bridge vlan-ids=10 ] tagged=ether1,ether8,ether24
  4. Copy or reference currently tagged interfaces for VLAN 20
  5. Execute set [ find bridge=bridge vlan-ids=20 ] tagged=ether1,ether8,ether24
  6. Copy or reference currently tagged interfaces for VLAN 30
  7. Execute set [ find bridge=bridge vlan-ids=30 ] tagged=ether1,ether8,ether14,ether24

We’re looking at at least 7 steps (4 commands) along with copying/pasting in order to accomplish something that should be able to be done with just 1 command.

Imagine a future with:

/interface bridge vlan
set interface=ether1 vlan-tagged=1,2,4-5
set interface=ether2 vlan-tagged=6-7 vlan-untagged=8-9,20
set interface=ether3 vlan-untagged=22-24
set interface=ether4,ether5,ether6 vlan-untagged=1