# VLAN+STP interaction.



## RitheshShenthar (Aug 9, 2013)

Hi,
       I am making a setup where one of the devices I'm using a FreeBSD 8 to act as a switch with 2 VLANs for 5 ports-

My FreeBSD box has 5 ports such that I need -
==============================
Interfaces em1, em4 in VLAN 100.
Interfaces em2, em3, em5 in VLAN 101.

 I've created a bridge, bridge0.
 I've created 5 VLAN devices, one for each parent NIC and assigned the VLANs as in the diagram.( 3 VLAN id 100, 2 VLAN id 101)
 I've added all VLAN devices to the bridge0.
 Currently the ports are running RSTP.

Now, the issues I am facing -

 I am unable to add VLAN devices to STP for some reason though I can add physical ports into STP mode- I searched for an answer as to why  this can't be done - haven't found one yet though others seemed to have  faced the same issue.


```
(TPC)# ifconfig
em0: flags=40008843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC>
    ether 00:30:48:2f:37:e6
    inet 10.133.1.114 netmask 0xfffffffc broadcast 10.133.1.115
    media: Ethernet autoselect (1000baseT <full-duplex>)
    status: active
em1: flags=40008943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC>
    ether 00:30:48:2f:37:e7
    inet 9.0.0.1 netmask 0xffffff00 broadcast 9.0.0.255
    media: Ethernet autoselect (1000baseT <full-duplex>)
    status: active
em2: flags=40008943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM>
    ether 00:04:23:d4:4a:5a
    inet 1.0.0.3 netmask 0xffffff00 broadcast 1.0.0.255
    media: Ethernet autoselect (1000baseT <full-duplex>)
    status: active
em3: flags=40008943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM>
    ether 00:04:23:d4:4a:5b
    inet 1.0.0.4 netmask 0xffffff00 broadcast 1.0.0.255
    media: Ethernet autoselect (1000baseT <full-duplex>)
    status: active
em4: flags=40008943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM>
    ether 00:04:23:d5:35:60
    media: Ethernet autoselect (1000baseT <full-duplex>)
    status: active
em5: flags=40008943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM>
    ether 00:04:23:d5:35:61
    media: Ethernet autoselect (1000baseT <full-duplex>)
    status: active
ipfw0: flags=8801<UP,SIMPLEX,MULTICAST> metric 0 mtu 65536
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
    options=3<RXCSUM,TXCSUM>
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x8 
    inet6 ::1 prefixlen 128 
    inet 127.0.0.1 netmask 0xff000000 
    nd6 options=3<PERFORMNUD,ACCEPT_RTADV>
vlan0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=3<RXCSUM,TXCSUM>
    ether 00:30:48:2f:37:e7
    media: Ethernet autoselect (1000baseT <full-duplex>)
    status: active
    vlan: 101 parent interface: em1
vlan1: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=3<RXCSUM,TXCSUM>
    ether 00:04:23:d5:35:60
    media: Ethernet autoselect (1000baseT <full-duplex>)
    status: active
    vlan: 101 parent interface: em4
vlan2: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=3<RXCSUM,TXCSUM>
    ether 00:04:23:d4:4a:5a
    media: Ethernet autoselect (1000baseT <full-duplex>)
    status: active
    vlan: 100 parent interface: em2
vlan3: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=3<RXCSUM,TXCSUM>
    ether 00:04:23:d4:4a:5b
    media: Ethernet autoselect (1000baseT <full-duplex>)
    status: active
    vlan: 100 parent interface: em3
vlan4: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=3<RXCSUM,TXCSUM>
    ether 00:04:23:d5:35:61
    media: Ethernet autoselect (1000baseT <full-duplex>)
    status: active
    vlan: 100 parent interface: em5
bridge0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
    ether 26:9c:98:1f:32:0a
    id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
    maxage 20 holdcnt 6 proto rstp maxaddr 100 timeout 1200
    root id 00:00:00:00:00:00 priority 0 ifcost 0 port 0
    member: vlan4 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
            ifmaxaddr 0 port 13 priority 128 path cost 20000
    member: vlan3 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
            ifmaxaddr 0 port 12 priority 128 path cost 20000
    member: vlan2 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
            ifmaxaddr 0 port 11 priority 128 path cost 20000
    member: vlan1 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
            ifmaxaddr 0 port 10 priority 128 path cost 20000
    member: vlan0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
            ifmaxaddr 0 port 9 priority 128 path cost 20000
```


```
(TPC-E1-17:wheel)# ifconfig bridge0 stp vlan0 stp vlan1 stp vlan2 stp vlan3 stp vlan4
ifconfig: unable to set bridge flags: Invalid argument
```

 Is there a way to have multiple STP instances on the same FreeBSD machine? I need each VLAN to have a different root bridge, different STP instance. If this is possible, how do I do it?        
When I enable this setup, will there be only 1 STP for all VLANs? I did some research and I found that only 1 single instance should exist across all VLANs and STP is VLAN agnostic. But my thinking is that BPDUs from different VLANs shouldn't mix as broadcast domains are different? (as far as I know PVST/MSTP is not possible on FreeBSD).

 If I need to forward packets incoming on one VLAN into the other VLAN, would a normal static route do? Or do I need something else? Eg: The destination network incoming on VLAN 100 needs to be sent out of a port in VLAN 101.


----------

