Hi!
It seems like official way to do VLANs and bridges it to create VLAN interfaces on the physical interfaces and then create a bridge for each VLAN
Something like this:
But this gets quickly out of hand when there are bunch of vlans or physical interfaces
Somewhat cleaner option would be to attach all of the physical interfaces to a single bridge and then tap VLANs from there. Unfortunaly you can't add VLAN interface to a bridge directly. But if you create a epair(4) interface and add one end to the bridge and use other end for VLANs then it works quite well. All the traffic is nicely bridged and VLANs can be easily added if needed.
So the question is that are there any mayor downsides to using this epair hack to do VLANs on top of the bridge?
It seems like official way to do VLANs and bridges it to create VLAN interfaces on the physical interfaces and then create a bridge for each VLAN
Something like this:
Code:
ifconfig em0 name lan0 up
ifconfig em1 name lan1 up
ifconfig vlan create vlan 10 vlandev lan0 name lan0.10
ifconfig vlan create vlan 10 vlandev lan1 name lan1.10
ifconfig vlan create vlan 101 vlandev lan0 name lan0.101
ifconfig vlan create vlan 101 vlandev lan1 name lan1.101
ifconfig bridge create name br-test.10 up
ifconfig br-test.10 addm lan0.10 stp lan0.10 addm lan1.10 stp lan1.10
ifconfig bridge create name br-test.101 up
ifconfig br-test.101 addm lan0.101 stp lan0.101 addm lan1.101 stp lan1.101
ifconfig br-test.10 192.168.10.2/24
ifconfig br-test.101 192.168.101.2/24
But this gets quickly out of hand when there are bunch of vlans or physical interfaces
Somewhat cleaner option would be to attach all of the physical interfaces to a single bridge and then tap VLANs from there. Unfortunaly you can't add VLAN interface to a bridge directly. But if you create a epair(4) interface and add one end to the bridge and use other end for VLANs then it works quite well. All the traffic is nicely bridged and VLANs can be easily added if needed.
Code:
ifconfig em0 name lan0 up
ifconfig em1 name lan1 up
ifconfig bridge create name br-test up
ifconfig br-test addm lan0 stp lan0 addm lan1 stp lan1
ifconfig epair create name br-test-trunk up
ifconfig epair0b name br-test-con up
ifconfig br-test addm br-test-con
ifconfig vlan create vlan 10 vlandev br-test-trunk name br-test.10 up
ifconfig vlan create vlan 101 vlandev br-test-trunk name br-test.101 up
ifconfig br-test.10 192.168.10.2/24
ifconfig br-test.101 192.168.101.2/24
So the question is that are there any mayor downsides to using this epair hack to do VLANs on top of the bridge?