VLAN, Bridge, HW Offload and Trunk Ports

Hi,

I am using a RB750 GL with ROS 6.43. ether1 is a trunk port with Vlan 1/100/200/300/400/500. ether2 should be a tagged trunk “out” so all the vlans from trunk ether1 are switched to ether2.
ether3-5 are untagged and should not be the focus of the question.

Here is my config:

/interface bridge
add fast-forward=no name=bridge1 protocol-mode=none
/interface ethernet
set [ find default-name=ether1 ] name=ether1_trunk
set [ find default-name=ether2 ] name=ether2_trunk_out
set [ find default-name=ether3 ] name=ether3_Heimnetz
set [ find default-name=ether4 ] name=ether4_SmartHome
set [ find default-name=ether5 ] name=ether5_IPv6
/interface vlan
add interface=bridge1 name=vlan1_Heimnetz vlan-id=1
/interface ethernet switch port
set 0 vlan-header=add-if-missing
set 1 vlan-header=add-if-missing
set 2 default-vlan-id=1 vlan-header=always-strip vlan-mode=fallback
set 3 default-vlan-id=400 vlan-header=always-strip vlan-mode=fallback
set 4 vlan-mode=fallback
set 5 vlan-header=add-if-missing vlan-mode=secure
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
#error exporting /interface bridge calea
/interface bridge port
add bridge=bridge1 interface=ether1_trunk trusted=yes
add bridge=bridge1 interface=ether2_trunk_out trusted=yes
/interface ethernet switch vlan
add independent-learning=yes ports=ether1_trunk,ether2_trunk_out,switch1-cpu \
    switch=switch1 vlan-id=1
add independent-learning=yes ports=ether1_trunk,ether2_trunk_out switch=\
    switch1 vlan-id=100
add independent-learning=yes ports=ether1_trunk,ether2_trunk_out switch=\
    switch1 vlan-id=200
add independent-learning=yes ports=ether1_trunk,ether2_trunk_out switch=\
    switch1 vlan-id=300
add independent-learning=yes ports=ether1_trunk,ether2_trunk_out switch=\
    switch1 vlan-id=400
add independent-learning=yes ports=ether1_trunk,ether2_trunk_out switch=\
    switch1 vlan-id=500
/ip address
add address=192.168.0.190/24 interface=vlan1_Heimnetz network=192.168.0.0
/ip dhcp-client
add dhcp-options=hostname,clientid disabled=no interface=vlan1_Heimnetz
/ip dns
set servers=192.168.0.254
#error exporting /ip firewall calea
/ip route
add distance=1 gateway=192.168.0.254

I can ping my mikrotik on IP 192.168.0.190. On ether2 there is another router on a stick attached with IP 192.168.0.229 on vlan1. Its also pingable.
So now if I change vlan mode of ether1 or ether2 to “secure” both pings fail suddenly. Can anybody expain this to me? :open_mouth:
ether1 is connected to a HP 1820-24G switch, just for your information.
I think “secure” checks all the vlan tags on ether1 if they exist in the vlan table of the switch. I in my opinion they exist…

Using vlan-id=1 calls for trouble. I never found out for sure if that VLAN is considered untagged or not. I tried something similar and didn’t work. When I chose another VLAN id (e.g. 2), it just started to work.

Another thing: if you’re using vlan-header=add-if-missing, then you probably have to use default-vlan-id setting. Or else switch chip doesn’t know explicitly which VLAN id to add to untagged packets on egress.

Well I have already considered changing my homenet vlan to something else than 1 for all devices. But this is a lot for work to do :frowning: I would like to find another solution/explanation

Another issue, I have just noticed that my vlan100 is not forwarded to the router on the stick on ether2. There a DHCP client does not get an ip :frowning: Just vlan1 is working.

The point is that Mikrotik’s software bridge (/ip interface bridge) supports tagless frames internally, which normal switches don’t. So if you forget about the switch chip for a moment, and you imagine what happens when vlan-filtering=yes on a bridge and a tagless ingress frame comes to an ethernet port which is a member port of that bridge. On a “normal” switch, the pvid setting of that port (or its equivalent in the vocabulary of another manufacturer) determines with what VLAN ID the frame will be tagged, and that’s it, no more mysteries.

On Mikrotik, this works too, except if the pvid of the port matches the pvid of the bridge of which the port is a member - in such case, the tagless frame from the wire makes it to the bridge itself tagless; consistently, also a frame which came tagged from outside with a VID matching bridge’s pvid value will get untagged. So if pvid of /interface bridge is set to N, attaching an /interface vlan with vlan-id=N to that bridge won’t work because no frame tagged with VID N will ever arrive to the tagged side of the /interface vlan (which is another “member port” of the bridge).

It is not clear to me how the above works with vlan-filtering=no on the bridge, which is how you currently run it - I know that the /interface bridge port and /interface bridge vlan settings are ignored in such case but whether the pvid value of /interface bridge is ignored as well is not clear to me.

Now as Metod wrote above, vlan-header=add-if-missing should be paired with explicitly setting default-vlan-id to 1, because nobody really knows what the default auto means. Even worse, the current revision of the Switch chip wiki states that the 8327 actually ignores the vlan-header setting and only looks at default-vlan-id for both ingress and egress.

So if you set it that way and keep vlan-filtering=no for the bridge (which you have to do as setting it to yes disables the “hardware acceleration”, i.e. disables frame forwarding by the switch chip itself), there is a good chance that the switch chip will tag tagless ingress frames with VID 1, the bridge won’t touch them, and the /interface vlan vlan-id=1 will receive them. But it is not a sure thing; if it does not work, set the bridge’s pvid value to some VID unused in your network and see whether it helps.

Hm a bridge with disabled VLAN filtering does not have a PVID. Or am I misunderstanding something? You simply cannot set them.

Now I have added a vlan100 interface on my bridge. A dhcp client on this interface does not get an IP address. It should work because VLAN id 100 is attached to switch1cpu in the swich menu. What do you think?

You have to add switch-cpu to the list of ports in switch vla for VLAN id 100 … or else switch chip doesn’t communicate it with bridge. This part is missing from config you posted above.

If I do understand the bridges, you have two option.

  1. Bridge vlan-filter=off (old way)
    This is the old way and you use one Bridge pr VLAN
  2. Bridge vlan-filter=on (new way >=6.41 software.)
    With this you can use one Bridge that handles VLAN tagged packet

See my graphical attempt to learn how it works here:
http://forum.mikrotik.com/t/sofware-vlan-bridge-on-ruteros-explained/122534/1

@Jotne, forget about bridges in this particular case, the OP wants to make VLAN filtering work in hardware, which the 8327 “chip” (actually, a functional block within an SoC) in RB750GL can do (provided that you don’t require any STP flavor to run). So the bridging part is there only to make the local /interface vlan work, the rest is handled by the switch “chip” itself.

I have added them meanwhile as you said but DHCP does not get an IP address

/interface bridge
add fast-forward=no name=bridge1 protocol-mode=none
/interface ethernet
set [ find default-name=ether1 ] name=ether1_trunk
set [ find default-name=ether2 ] name=ether2_trunk_out
set [ find default-name=ether3 ] name=ether3_Heimnetz
set [ find default-name=ether4 ] name=ether4_SmartHome
set [ find default-name=ether5 ] name=ether5_IPv6
/interface vlan
add interface=bridge1 name=vlan1_Heimnetz vlan-id=1
add interface=bridge1 name=vlan100_GuestWLAN vlan-id=100
/interface ethernet switch port
set 0 vlan-header=add-if-missing
set 1 vlan-header=add-if-missing
set 2 default-vlan-id=1 vlan-header=always-strip vlan-mode=fallback
set 3 default-vlan-id=400 vlan-header=always-strip vlan-mode=fallback
set 4 vlan-mode=fallback
set 5 default-vlan-id=1 vlan-header=add-if-missing vlan-mode=secure
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
#error exporting /interface bridge calea
/interface bridge port
add bridge=bridge1 interface=ether1_trunk trusted=yes
add bridge=bridge1 interface=ether2_trunk_out trusted=yes
/interface ethernet switch vlan
add independent-learning=yes ports=ether1_trunk,ether2_trunk_out,switch1-cpu \
    switch=switch1 vlan-id=1
add independent-learning=yes ports=ether1_trunk,ether2_trunk_out,switch1-cpu \
    switch=switch1 vlan-id=100
add independent-learning=yes ports=ether1_trunk,ether2_trunk_out switch=\
    switch1 vlan-id=200
add independent-learning=yes ports=ether1_trunk,ether2_trunk_out switch=\
    switch1 vlan-id=300
add independent-learning=yes ports=ether1_trunk,ether2_trunk_out switch=\
    switch1 vlan-id=400
add independent-learning=yes ports=ether1_trunk,ether2_trunk_out switch=\
    switch1 vlan-id=500
/ip address
add address=192.168.0.190/24 interface=vlan1_Heimnetz network=192.168.0.0
/ip dhcp-client
add dhcp-options=hostname,clientid disabled=no interface=vlan100_GuestWLAN
/ip dns
set servers=192.168.0.254
#error exporting /ip firewall calea
/ip route
add distance=1 gateway=192.168.0.254

@Jotne
Yes I want to do VLAN with hardware offloading in other words I want to use the onboard switch chip

if you want to use hw offloading, put every port in coresponding bridge, configure each port in switch chip as secure including switch chip. Every VLAN that needs to reach the router must be configured in switch vlan.

leave one port extra for management until everything works!

So now every VLAN gets an IP on the interface except vlan1! :confused:
In my opinion the configuration should be fine…

/interface bridge
add fast-forward=no name=bridge1 protocol-mode=none
/interface ethernet
set [ find default-name=ether1 ] name=ether1_trunk
set [ find default-name=ether2 ] name=ether2_trunk_out
set [ find default-name=ether3 ] name=ether3_Heimnetz
set [ find default-name=ether4 ] name=ether4_SmartHome
set [ find default-name=ether5 ] name=ether5_IPv6
/interface vlan
add interface=bridge1 name=vlan1_Heimnetz vlan-id=1
add interface=bridge1 name=vlan100_GuestWLAN vlan-id=100
add interface=bridge1 name=vlan200_ vlan-id=200
add interface=bridge1 name=vlan300_ vlan-id=300
add interface=bridge1 name=vlan400_ vlan-id=400
add interface=bridge1 name=vlan500_ vlan-id=500
/interface ethernet switch port
set 0 default-vlan-id=1 vlan-header=add-if-missing vlan-mode=secure
set 1 default-vlan-id=1 vlan-header=add-if-missing vlan-mode=secure
set 2 default-vlan-id=1 vlan-header=always-strip vlan-mode=fallback
set 3 default-vlan-id=400 vlan-header=always-strip vlan-mode=fallback
set 4 vlan-mode=fallback
set 5 default-vlan-id=1 vlan-header=add-if-missing vlan-mode=secure
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
#error exporting /interface bridge calea
/interface bridge port
add bridge=bridge1 interface=ether1_trunk trusted=yes
add bridge=bridge1 interface=ether2_trunk_out trusted=yes
add bridge=bridge1 interface=vlan100_GuestWLAN pvid=100 trusted=yes
add bridge=bridge1 interface=vlan1_Heimnetz trusted=yes
/interface ethernet switch vlan
add independent-learning=yes ports=ether1_trunk,ether2_trunk_out,switch1-cpu \
    switch=switch1 vlan-id=1
add independent-learning=yes ports=ether1_trunk,ether2_trunk_out,switch1-cpu \
    switch=switch1 vlan-id=100
add independent-learning=yes ports=ether1_trunk,ether2_trunk_out,switch1-cpu \
    switch=switch1 vlan-id=200
add independent-learning=yes ports=ether1_trunk,ether2_trunk_out,switch1-cpu \
    switch=switch1 vlan-id=300
add independent-learning=yes ports=ether1_trunk,ether2_trunk_out,switch1-cpu \
    switch=switch1 vlan-id=400
add independent-learning=yes ports=ether1_trunk,ether2_trunk_out,switch1-cpu \
    switch=switch1 vlan-id=500
/ip address
add address=192.168.0.190/24 interface=vlan1_Heimnetz network=192.168.0.0
/ip dhcp-client
add dhcp-options=hostname,clientid interface=vlan400_
/ip dns
set servers=192.168.0.254
#error exporting /ip firewall calea
/ip route
add distance=1 gateway=192.168.0.254

B…dy export where the switch ports are identified by id (0 to 5) rather than name.

Never mind - this way you’ve set the switch1-cpu port to behave as an access one for VID 1, i.e. prior to being sent to the CPU, frames tagged with VID1 get untagged. So set default-vlan-id for switch1-cpu to 0 instead of current 1 and you should be good, because frames tagged with VID 1 will stay tagged on the bridge, so the /interface vlan vlan-id=1 will get them the way it can recognize them.

The other posssibility is to keep the switch1-cpu port configuration as-is (with default-vlan-id=1) and re-attach the IP configuration (IP address and DHCP server) from /interface vlan vlan-id=1 (which thus becomes useless) to the /interface bridge itself. That means that internally the VID 1 will exist tagless.

Great it works! Thanks a lot! I struggled a lot with this new vlan/bridge and hardware offloading stuff, it a steep learning curve :frowning:
Maybe the mikrotik guys should add such a config to the wiki, I think a lot of people are having issues here..

/interface bridge
add fast-forward=no name=bridge1 protocol-mode=none
/interface ethernet
set [ find default-name=ether1 ] name=ether1_trunk
set [ find default-name=ether2 ] name=ether2_trunk_out
set [ find default-name=ether3 ] name=ether3_Heimnetz
set [ find default-name=ether4 ] name=ether4_SmartHome
set [ find default-name=ether5 ] name=ether5_IPv6
/interface vlan
add interface=bridge1 name=vlan1_Heimnetz vlan-id=1
add interface=bridge1 name=vlan100_GuestWLAN vlan-id=100
add interface=bridge1 name=vlan200_ vlan-id=200
add interface=bridge1 name=vlan300_ vlan-id=300
add interface=bridge1 name=vlan400_ vlan-id=400
add interface=bridge1 name=vlan500_ vlan-id=500
/interface ethernet switch port
set 0 default-vlan-id=0 vlan-header=add-if-missing vlan-mode=secure
set 1 default-vlan-id=0 vlan-header=add-if-missing vlan-mode=secure
set 2 default-vlan-id=1 vlan-header=always-strip vlan-mode=fallback
set 3 default-vlan-id=400 vlan-header=always-strip vlan-mode=fallback
set 4 vlan-mode=fallback
set 5 default-vlan-id=0 vlan-header=add-if-missing vlan-mode=secure
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
#error exporting /interface bridge calea
/interface bridge port
add bridge=bridge1 interface=ether1_trunk trusted=yes
add bridge=bridge1 interface=ether2_trunk_out trusted=yes
add bridge=bridge1 interface=vlan100_GuestWLAN pvid=100 trusted=yes
add bridge=bridge1 interface=vlan1_Heimnetz trusted=yes
/interface ethernet switch vlan
add independent-learning=yes ports=ether1_trunk,ether2_trunk_out,switch1-cpu \
    switch=switch1 vlan-id=1
add independent-learning=yes ports=ether1_trunk,ether2_trunk_out,switch1-cpu \
    switch=switch1 vlan-id=100
add independent-learning=yes ports=ether1_trunk,ether2_trunk_out,switch1-cpu \
    switch=switch1 vlan-id=200
add independent-learning=yes ports=ether1_trunk,ether2_trunk_out,switch1-cpu \
    switch=switch1 vlan-id=300
add independent-learning=yes ports=ether1_trunk,ether2_trunk_out,switch1-cpu \
    switch=switch1 vlan-id=400
add independent-learning=yes ports=ether1_trunk,ether2_trunk_out,switch1-cpu \
    switch=switch1 vlan-id=500
/ip address
add address=192.168.0.190/24 interface=vlan1_Heimnetz network=192.168.0.0
/ip dhcp-client
add dhcp-options=hostname,clientid disabled=no interface=vlan1_Heimnetz
/ip dns
set servers=192.168.0.254
#error exporting /ip firewall calea
/ip route
add distance=1 gateway=192.168.0.254