VPN and VLANs · Topic 7 of 7

VLANs on the Switch Chip of a RouterBOARD

Learn how RouterBOARD switch chips forward VLAN traffic in hardware, how the older switch menu relates to bridge hardware offload, and its main settings.

  • 5 min
In a nutshell
  • A switch chip forwards traffic between its ports in hardware, without the CPU.
  • Only ports on the same chip can be switched in hardware together.
  • The CPU port must be a VLAN member for the router to use the VLAN.

What it is

Many RouterBOARD models contain a switch chip that forwards frames between Ethernet ports in hardware.

Traffic that stays inside the chip does not use the CPU, so it runs at wire speed. The CPU is only involved for traffic that must be routed, filtered or otherwise processed by RouterOS.

The chip can also handle VLANs, so ports can be separated into VLANs without loading the CPU.

Host Aport ether3in chipSwitch chipforwards in hardwarein chipHost Bport ether4Switch chipcpu port, only routed trafficCPURouterOS

How it works

Ports on the same chip are switched in hardware, and a configuration decides how VLAN tags are handled.

Which chip a port belongs to

Each model has one or more switch chips, and each chip serves a group of ports. A port on a different chip, or one that is not connected to a chip at all, cannot be switched in hardware with the others.

The chip is connected to the CPU through an internal port. In the switch menu this appears as a CPU port, so the router itself can take part in a VLAN.

/interface ethernet switch print
/interface ethernet switch port print

Two ways to configure it

RouterOS has a long history of two methods for VLANs on a switch chip. The method you use depends on the model and the RouterOS version.

MethodHow ports are joinedVLAN control
Switch menu, older stylePorts linked as master and slaveVLAN table in the switch menu
Bridge with hardware offloadPorts in one bridgeBridge VLAN settings, offloaded when the chip supports it

In older RouterOS v6 versions, a slave port was joined to a master port with master-port. Since v6.41, the recommended way is a bridge, and the bridge uses hardware offload when the chip allows it.

Not every chip can offload bridge VLAN filtering. On such devices, enabling VLAN filtering on the bridge may move forwarding to the CPU, and the speed drops.

The switch menu settings

In the switch menu, a VLAN table lists which ports belong to which VLAN, and each port has settings for VLAN handling.

/interface ethernet switch vlan add switch=switch1 vlan-id=10 ports=ether3,ether2,switch1-cpu
/interface ethernet switch port set ether3 vlan-mode=secure vlan-header=always-strip default-vlan-id=10
/interface ethernet switch port set ether2 vlan-mode=secure vlan-header=add-if-missing

The table entry says that VLAN 10 exists on ether3, ether2 and the CPU port. The port settings then control how frames enter and leave.

SettingMeaning
vlan-modeHow strictly the chip checks VLAN membership, from disabled to secure
vlan-headerWhether the tag is added, kept or removed on egress
default-vlan-idVLAN given to untagged frames that enter the port

An access port strips the tag on the way out, with always-strip, and gives untagged frames the default VLAN. A trunk port keeps the tag, using add-if-missing.

Hostuntaggedether3, default VLAN 10ChipVLAN tableether2, tag keptRouterVLAN 10 tagged

The CPU port

For the router to have an address in a VLAN, the CPU port must be a member of the VLAN table entry. Without it, hosts cannot reach the router in that VLAN, even though they can reach each other.

Bridge hardware offload

With the bridge method, you create a bridge, add the ports, and RouterOS programs the chip for you.

/interface bridge add name=bridge1
/interface bridge port add bridge=bridge1 interface=ether3 pvid=10
/interface bridge port print

The port list shows whether a port is offloaded to hardware, by a flag in the print. If a feature forces software handling, the flag is absent.

Choosing between the methods

Use the bridge method on current RouterOS when your hardware supports it. Use the switch menu on models and versions where the documentation tells you to. Do not configure the same ports with both methods.

Verifying

/interface ethernet switch vlan print
/interface bridge port print
/interface print stats
Exam tip

If VLAN traffic seems slow, check that the ports are offloaded in the bridge port list. CPU load shows whether the chip is doing the work.

What to remember for the exam

Six facts cover most questions on this topic.

  • A switch chip forwards traffic between its ports in hardware, without the CPU.
  • Only ports on the same chip can be switched in hardware together.
  • The CPU port must be a VLAN member for the router to use the VLAN.
  • vlan-mode, vlan-header and default-vlan-id are per port settings in the switch menu.
  • From v6.41, a bridge with hardware offload is the recommended method.
  • Not every chip can offload bridge VLAN filtering.
Watch out

Do not mix the older switch menu VLAN settings and bridge VLAN filtering on the same ports. The result is hard to predict.

Common mistakes

These four errors appear often.

Leaving the CPU port out of the VLAN table. Hosts reach each other but never the router.

Mixing the two configuration methods. Settings from the switch menu and the bridge fight over the same ports.

Assuming every port is on the chip. A port on another chip is switched by the CPU, which is slower.

Forgetting the default VLAN on an access port. Untagged frames then enter the wrong VLAN, or none.

Check yourself

Work through these three questions.

  • Why is traffic between ports on one switch chip fast?

    The chip forwards it in hardware, so the CPU is not involved. Only traffic that needs routing or filtering goes to the CPU.

  • What must be in the VLAN table so the router can use a VLAN?

    The CPU port must be a member of the VLAN entry. Without it, hosts cannot reach the router in that VLAN.

  • What do default-vlan-id and vlan-header control on a port?

    default-vlan-id gives untagged ingress frames their VLAN. vlan-header controls whether the tag is added, kept or removed on egress.

Topic 7 of 7 in VPN and VLANs

Test yourself on VPN and VLANs

The full MikroTik MTCRE question bank has 417 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by MikroTik. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.