Manual:CRS3xx VLANs with Bonds

From MikroTik Wiki
Jump to navigation Jump to search

Applies to RouterOS: v6.42 +


This page will show how to configure multiple switches to use bonding interfaces and port based VLANs, it will also show a working example with a DHCP-Server, interVLAN routing, management IP and invalid VLAN filtering configuration.


Warning: This article applies to CRS3xx series devices and not CRS1xx/CRS2xx. For a similar setup for CRS1xx/CRS2xx series switches you can check CRS1xx/2xx VLANs with Trunks guide.

Alt text
CRS3xx bonds and port based VLANs

Note: For this network topology we will be using two CRS326-24G-2S+, one CRS317-1G-16S+ and one CCR1072-1G-8S+, but same principles can be applied to any CRS3xx series devices and a router.

In this setup SwitchA and SwitchC will tag all traffic from ports ether1-ether8 to VLAN ID 10, ether9-ether16 to VLAN ID 20, ether17-ether24 to VLAN ID 30. Management will only be possible if user is connecting with tagged traffic with VLAN ID 99 from ether1 on SwitchA or SwitchB, connecting to all devices will also be possible from the router using tagged traffic with VLAN ID 99. SFP+ ports in this setup are going to be used as VLAN trunk ports while being in a bond to create a LAG interface.

Port switching

All switches in this setup require that all used ports are switched together (except for ports that are going to be part of a bonding interface). Use these commands on SwitchA and SwitchC:

/interface bridge
add name=bridge vlan-filtering=no
/interface bridge port
add bridge=bridge interface=ether1 pvid=10 hw=yes
add bridge=bridge interface=ether2 pvid=10 hw=yes
add bridge=bridge interface=ether3 pvid=10 hw=yes
add bridge=bridge interface=ether4 pvid=10 hw=yes
add bridge=bridge interface=ether5 pvid=10 hw=yes
add bridge=bridge interface=ether6 pvid=10 hw=yes
add bridge=bridge interface=ether7 pvid=10 hw=yes
add bridge=bridge interface=ether8 pvid=10 hw=yes
add bridge=bridge interface=ether9 pvid=20 hw=yes
add bridge=bridge interface=ether10 pvid=20 hw=yes
add bridge=bridge interface=ether11 pvid=20 hw=yes
add bridge=bridge interface=ether12 pvid=20 hw=yes
add bridge=bridge interface=ether13 pvid=20 hw=yes
add bridge=bridge interface=ether14 pvid=20 hw=yes
add bridge=bridge interface=ether15 pvid=20 hw=yes
add bridge=bridge interface=ether16 pvid=20 hw=yes
add bridge=bridge interface=ether17 pvid=30 hw=yes
add bridge=bridge interface=ether18 pvid=30 hw=yes
add bridge=bridge interface=ether19 pvid=30 hw=yes
add bridge=bridge interface=ether20 pvid=30 hw=yes
add bridge=bridge interface=ether21 pvid=30 hw=yes
add bridge=bridge interface=ether22 pvid=30 hw=yes
add bridge=bridge interface=ether23 pvid=30 hw=yes
add bridge=bridge interface=ether24 pvid=30 hw=yes

Note: If required, it is possible to use STP/RSTP/MSTP and IGMP Snooping with hardware offloading, make sure your device supports it.


Warning: In this setup vlan-filtering is required, but it should be disabled while you are setting up the device. If you create a bridge with vlan-filtering enabled at the beginning, then you might loose access to the switch while you are configuring it. It is recommended to enable vlan-filtering only when management port and bridge VLAN table is configured.


Bonding interfaces are used when a larger amount of bandwidth is required, this is done by creating a link aggregation group, which also provides hardware automatic failover and load balancing for CRS3xx series switches. By adding two 10Gbps interfaces to a bonding, you can increase the theoretical bandwidth limit to 20Gbps. Make sure that all bonded interfaces are linked to the same speed rates.


Note: CRS3xx series switches aggregate traffic using the built-in Switch Chip without using CPU resources, to route the traffic a router with a powerful CPU is required to handle the aggregated traffic.

To create a 20Gbps bonding interface from sfp-sfpplus1 and sfp-sfpplus2 between SwitchA to SwitchB and between SwitchC to SwitchB, use these commands on SwitchA and SwitchC:

/interface bonding
add mode=802.3ad name=bond_1-2 slaves=sfp-sfpplus1,sfp-sfpplus2

To create a 40Gbps bonding interface between SwitchB and the Router and 20Gbps bonding interfaces between SwitchA and SwitchC, use these commands on SwitchB:

/interface bonding
add mode=802.3ad name=bond_1-2 slaves=sfp-sfpplus1,sfp-sfpplus2
add mode=802.3ad name=bond_3-4 slaves=sfp-sfpplus3,sfp-sfpplus4
add mode=802.3ad name=bond_5-6-7-8 slaves=sfp-sfpplus5,sfp-sfpplus6,sfp-sfpplus7,sfp-sfpplus8

When all the bonding interfaces are create, they must be added as a bridge port. Use these commands on SwitchA and SwitchB:

/interface bridge port
add bridge=bridge interface=bond_1-2 hw=yes

Add all bonding interfaces to a single bridge on SwitchB by using these commands on SwitchB:

/interface bridge port
add bridge=bridge interface=bond_1-2 hw=yes
add bridge=bridge interface=bond_3-4 hw=yes
add bridge=bridge interface=bond_5-6-7-8 hw=yes

In our case the Router needs a software based bonding interface, use these commands on Router:

/interface bonding
add mode=802.3ad name=bond_1-2-3-4 slaves=sfp-sfpplus1,sfp-sfpplus2,sfp-sfpplus3,sfp-sfpplus4

Note: Interface bonding does not create a interface with a larger link speed. Interface bonding creates a virtual interface that can load balance traffic over multiple interfaces. More details can be found in the LAG interfaces and load balancing page.

Management IP

It is very useful to create a management interface and assign an IP address to it in order to preserve access to the switch. This is also very useful when updating your switches since such traffic to the switch will be blocked when enabling invalid VLAN filtering.

Create a VLAN interface on SwitchA, SwitchB and SwitchC:

/interface vlan
add interface=bridge name=MGMT vlan-id=99

The Router needs the VLAN interface to be created on the bonding interface, use these commands to create a VLAN interface on Router':

/interface vlan
add interface=bond_1-2-3-4 name=MGMT vlan-id=99

Note: VLAN interface must be created on the bridge interface since it is the only interface that will be able to communicate the CPU.

For this guide we are going to use these addresses for each device:

Address Device Router SwitchA SwitchB SwitchC

Add an IP address for each device on the VLAN interface (change X to appropriate number):

/ip address
add address=192.168.99.X/24 interface=MGMT

Don't forget to add the default gateway and specify a DNS server:

/ip route
add gateway=
/ip dns
set servers=

Add the IP address on the Router:

/ip address
add address= interface=MGMT

Invalid VLAN filtering

Enable ingress traffic filtering for more security, use these commands on SwitchA, SwitchB and SwitchC:

/interface bridge port
set [f] ingress-filtering=yes

Since most ports on SwitchA and SwitchC are going to be access ports, you can set all ports to accept only certain types of packets, in this case we will want SwitchA and SwitchC to only accept untagged packets, use these commands on SwitchA and SwitchC:

/interface bridge port
set [f] frame-types=admit-only-untagged-and-priority-tagged

There is an exception for frame types on SwitchA and SwitchB, in this setup access to management port is required from ether1, bonding interfaces require that only tagged traffic can be forwarded. Use these commands on SwitchA and SwitchC:

/interface bridge port
set [find where interface=ether1] frame-types=admit-all
set [find where interface=bond_1-2] frame-types=admit-only-vlan-tagged

On SwitchB only tagged packets should be forwarded, use these commands on SwitchB:

/interface bridge port
set [f] frame-types=admit-only-vlan-tagged

It is required to setup bridge VLAN table. In this network setup we need to allow VLAN 10 on ether1-ether8, VLAN 20 on ether9-ether16, VLAN 30 on ether17-ether24, VLAN 10,20,30,99 on bond_1-2 and a special case for ether1 to allow to forward VLAN 99 on SwitchA and SwitchC. Use these commands on SwitchA and SwitchC:

/interface bridge vlan
add bridge=bridge tagged=bond_1-2 untagged=ether1,ether2,ether3,ether4,ether5,ether6,ether7,ether8 vlan-ids=10
add bridge=bridge tagged=bond_1-2 untagged=ether9,ether10,ether11,ether12,ether13,ether14,ether15,ether16 vlan-ids=20
add bridge=bridge tagged=bond_1-2 untagged=ether17,ether18,ether19,ether20,ether21,ether22,ether23,ether24 vlan-ids=30
add bridge=bridge tagged=bridge,bond_1-2,ether1 vlan-ids=99

Similarly it is required to setup bridge VLAN table for SwitchB. Use these commands on SwitchB:

/interface bridge vlan
add bridge=bridge tagged=bond_1-2,bond_3-4,bond_5-6-7-8 vlan-ids=10,20,30
add bridge=bridge tagged=bond_1-2,bond_3-4,bond_5-6-7-8,bridge vlan-ids=9

When everything is configured, VLAN filtering can be enabled. Use these commands on SwitchA, SwitchB and SwitchC:

/interface bridge
set bridge vlan-filtering=yes

Warning: Double check if port based VLANs are set up properly. If a mistake was made, you might loose access to the switch and it can only be regained by resetting the configuration or by using the serial console.

InterVLAN routing

To create InterVLAN routing, VLAN interface for each customer VLAN ID must be created on the router and must have an IP address assigned to it. The VLAN interface must be created on the bonding interface created previously.

Use these commands on the Router:

/interface vlan
add interface=bond_1-2-3-4 name=VLAN10 vlan-id=10
add interface=bond_1-2-3-4 name=VLAN20 vlan-id=20
add interface=bond_1-2-3-4 name=VLAN30 vlan-id=30
/ip address
add address= interface=VLAN10
add address= interface=VLAN20
add address= interface=VLAN30

Note: These commands are required for DHCP-Server. In case interVLAN routing is not desired but a DHCP-Server on a single router is required, then use Firewall Filter to block access between different subnets.


To get the DHCP-Server working for each VLAN ID, the server must be set up on the previously created VLAN interfaces (one server for each VLAN ID). Preferably each VLAN ID should have its own subnet and its own IP pool. DNS Server could be specified as the router's IP address for particular VLAN ID or a global DNS Server could be used, but this address must be reachable.

To set up the DHCP-Server, use these commands on the Router:

/ip pool
add name=VLAN10_POOL ranges=
add name=VLAN20_POOL ranges=
add name=VLAN30_POOL ranges=
/ip dhcp-server
add address-pool=VLAN10_POOL disabled=no interface=VLAN10 name=VLAN10_DHCP
add address-pool=VLAN20_POOL disabled=no interface=VLAN20 name=VLAN20_DHCP
add address-pool=VLAN30_POOL disabled=no interface=VLAN30 name=VLAN30_DHCP
/ip dhcp-server network
add address= dns-server= gateway=
add address= dns-server= gateway=
add address= dns-server= gateway=

In case the router's DNS Server is being used, don't forget to allow remote requests and make sure DNS Servers are configured on the router. Use these commands on the Router:

/ip dns
set allow-remote-requests=yes servers=

Warning: Make sure to secure your local DNS Server with Firewall from the outside when using allow-remote-requests set to yes since your DNS Server can be used for DDoS attacks if it is accessible from the Internet by anyone.

Don't forget to create NAT, assuming that sfp-sfpplus8 is used as WAN port, use these commands on the Router:

/ip firewall nat
add action=masquerade chain=srcnat out-interface=sfp-sfpplus8

Jumbo frames

One can increase the total throughput in such a setup by enabling jumbo frames. This reduces the packet overhead by increasing the Maximum Transmission Unit (MTU). If a device in your network does not support jumbo frames, then it will not benefit from a larger MTU. Usually the whole network does not support jumbo frames, but you can still benefit when sending data between devices that support jumbo frames, including all switches in the path.

In this case, if clients behind SwitchA and client behind SwitchC supports jumbo frames, then enabling jumbo frames will be beneficial. Before enabling jumbo frames, determine the MAX-L2MTU by using this command:

[admin@MikroTik] > /interface> print 
Flags: D - dynamic, X - disabled, R - running, S - slave 
 #     NAME                                TYPE       ACTUAL-MTU L2MTU  MAX-L2MTU      
 0  R  ether1                              ether            1500  1580       4064

Note: More information can be found in MTU manual page.

When MAX-L2MTU is determined, choose the MTU size depending on the traffic on your network, use this command on SwitchA, SwitchB and SwitchC:

/interface ethernet
set [ find ] l2mtu=4064 mtu=4040

Note: Don't forget to change the MTU on your client devices too, otherwise above mentioned settings will not have any effect.

See also

[ Top | Back to Content ]