Here’s excerpt from my home configuration. First I had RB951G with VLANs on switch … then I wanted to see how to configure the same on bridge, this time on RBD52G (hAP ac2). The last config was in production for a couple of days.
As the goal of my exercise on RBD52G was to learn how to configure VLANs on bridge, both configs are actually identical as to device behaviour … part from differences in WiFi (RB951G does not have 5GHz WiFi).
The scenario:
- ether1 is trunk port towards router. It carries VLANs 40,41,42 and 3999 all tagged
- ether2 is hybrid port for IPTV set-top box. It carries VLAN 40 untagged and 3999 tagged
- ether3, 4 and 5 are access ports for VLAN 42
- wifi runs two SSIDs: wifi-42 is for LAN access, tagged with VLAN 42 … and wifi-guest-41 is VAP for guest access (without password), tagged with VLAN 41
- VLAN 42 is main VLAN for home LAN and is also management VLAN, so device has vlan42 interface with its IP address.
Switch chip:
/interface bridge
add admin-mac=E4:8D:8C:49:EE:4A auto-mac=no fast-forward=no name=bridge
/interface ethernet
set [ find default-name=ether1 ] name=ether1-router
set [ find default-name=ether2 ] name=ether2-BOX
set [ find default-name=ether3 ] name=ether3-AV
set [ find default-name=ether4 ] name=ether4-TV
/interface vlan
add interface=bridge name=vlan-42 vlan-id=42
/interface ethernet switch
set 0 mirror-source=ether1-router
/interface ethernet switch port
set 0 vlan-mode=secure
set 1 default-vlan-id=40 vlan-header=always-strip vlan-mode=secure
set 2 default-vlan-id=42 vlan-header=always-strip vlan-mode=secure
set 3 default-vlan-id=42 vlan-header=always-strip vlan-mode=secure
set 4 default-vlan-id=42 vlan-header=always-strip vlan-mode=secure
set 5 vlan-header=add-if-missing vlan-mode=fallback
/interface ethernet switch vlan
add independent-learning=no ports=switch1-cpu,ether1-router,ether3-AV,ether4-TV,ether5 switch=switch1 vlan-id=42
add independent-learning=no ports=ether1-router,ether2-BOX switch=switch1 vlan-id=3999
add independent-learning=no ports=switch1-cpu,ether1-router switch=switch1 vlan-id=41
add independent-learning=no ports=switch1-cpu,ether1-router,ether2-BOX switch=switch1 vlan-id=40
/interface wireless
set [ find default-name=wlan1 ] band=2ghz-g/n channel-width=20/40mhz-eC \
country=slovenia disabled=no frequency=2472 frequency-mode=\
regulatory-domain mode=ap-bridge name=wifi-42 security-profile=mkxNet \
ssid=mkxNet vlan-id=42 vlan-mode=use-tag wireless-protocol=802.11 \
wps-mode=disabled
add disabled=no keepalive-frames=disabled mac-address=E4:8D:8C:49:EE:50 \
master-interface=wifi-42 multicast-buffering=disabled name=wifi-guest-41 \
ssid=mkxGuest vlan-id=41 vlan-mode=use-tag wds-cost-range=0 \
wds-default-cost=0 wps-mode=disabled
/interface bridge port
add bridge=bridge interface=ether1-router
add bridge=bridge interface=wifi-42
add bridge=bridge interface=wifi-guest-41
add bridge=bridge interface=ether2-BOX
add bridge=bridge interface=ether3-AV
add bridge=bridge interface=ether4-TV
add bridge=bridge interface=ether5
/ip address
add address=192.168.42.3/23 interface=vlan-42 network=192.168.42.0
/ip route
add distance=1 gateway=192.168.42.1
Note: you define PVID for ports in /interface ethernet switch port where you also define how tags are treated on egress (option vlan-header). You need to add switch-cpu to the list of VLAN member ports for any VLAN to which router needs access (it is then present on bridge as tagged).
Settings for port 5 (=switch-port) are probably weird, it’s legacy from the time when I was doing the config and my knowledge was even worse than it’s now.
Bridge VLAN way:
/interface bridge
add admin-mac=B8:69:F4:20:A5:49 auto-mac=no name=bridge protocol-mode=none vlan-filtering=yes
/interface ethernet
set [ find default-name=ether1 ] name=ether1-router
set [ find default-name=ether2 ] name=ether2-BOX
set [ find default-name=ether3 ] name=ether3-AV
set [ find default-name=ether4 ] name=ether4-TV
/interface vlan
add interface=bridge name=vlan-42 vlan-id=42
/interface wireless
set [ find default-name=wlan1 ] band=2ghz-g/n channel-width=20/40mhz-Ce \
country=slovenia disabled=no distance=indoors frequency=2452 \
frequency-mode=regulatory-domain mode=ap-bridge name=wifi-42-2G \
security-profile=mkxNet ssid=mkxNet vlan-id=42 vlan-mode=use-tag \
wireless-protocol=802.11 wps-mode=disabled
set [ find default-name=wlan2 ] band=5ghz-n/ac channel-width=20/40/80mhz-Ceee \
country=slovenia disabled=no distance=indoors frequency=auto \
frequency-mode=regulatory-domain mode=ap-bridge name=wifi-42-5G \
security-profile=mkxNet ssid=mkxNet vlan-id=42 vlan-mode=use-tag \
wireless-protocol=802.11 wps-mode=disabled
add disabled=no keepalive-frames=disabled mac-address=B8:69:F4:20:A5:50 \
master-interface=wifi-42-2G multicast-buffering=disabled name=\
wifi-guest-41 ssid=mkxGuest vlan-id=41 vlan-mode=use-tag wds-cost-range=0 \
wds-default-cost=0 wps-mode=disabled
/interface bridge port
add bridge=bridge frame-types=admit-only-vlan-tagged ingress-filtering=yes interface=ether1-router
add bridge=bridge interface=ether2-BOX pvid=40
add bridge=bridge interface=ether3-AV pvid=42
add bridge=bridge interface=ether4-TV pvid=42
add bridge=bridge interface=ether5 pvid=42
add bridge=bridge frame-types=admit-only-vlan-tagged ingress-filtering=yes interface=wifi-42-2G
add bridge=bridge frame-types=admit-only-vlan-tagged ingress-filtering=yes interface=wifi-42-5G
add bridge=bridge frame-types=admit-only-vlan-tagged ingress-filtering=yes interface=wifi-guest-41
/interface bridge vlan
add bridge=bridge tagged=bridge,ether1-router,wifi-42-2G,wifi-42-5G untagged=ether3-AV,ether4-TV,ether5 vlan-ids=42
add bridge=bridge tagged=ether1-router,ether2-BOX vlan-ids=3999
add bridge=bridge tagged=bridge,ether1-router,wifi-guest-41 vlan-ids=41
add bridge=bridge tagged=bridge,ether1-router untagged=ether2-BOX vlan-ids=40
/ip address
add address=192.168.42.6/23 interface=vlan-42 network=192.168.42.0
/ip route
add distance=1 gateway=192.168.42.1
Note that one needs to explicitly list all tagged and untagged ports connected to bridge in this case. Example: in switch chip way the wlan interfaces (“ports”) were only listed as bridge members, but their VLAN settings were only set in the wireless interface definition itself. In bridge VLAN, the wireless interface definition is identical to the one in switch chip case, but they need to be listed as tagged members of bridge in /interface bridge vlan section of configuration.
And my warning (again!): configuring VLANs on bridge disables HW offload so all wired intra-VLAN data passes CPU rather than switch chip alone. While RBD52G was quite capable of wire-speed transfers between two ether ports (and load on CPU indicated that another wire-speed between different pair of ports would be possible), good ole RB951G maxed CPU load (100%) with one (almost) wire-speed transfer between a pair of ether ports, so I assume another wire-speed transfer over different pair of ether ports would not be possible.
In first scenario (switch chip), RB951G doeasn’t even blink with eye while doing wire-speed transfers.