# Vlan not working



## kaschei (Oct 24, 2019)

What do I miss in my rc.conf ?

```
ifconfig_re0="up"
ifconfig_re0_2100="inet 10.212.100.14 netmask 255.255.252.0"
ifconfig_bridge0="addm re0.2100 up"
defaultrouter="10.212.100.254"
```
and after a reboot of the host I need to run:
`ifconfig bridge0 addm re0.2100 up`
to obtain contact with the vms


----------



## SirDice (Oct 24, 2019)

You're missing:

```
vlans_re0="2100"
```
This creates the actual vlan(4) interface(s).


----------



## kaschei (Oct 24, 2019)

Sorry I missed one line. My rc.conf looks like this:

vlans_re0="2100"
ifconfig_re0="up"
ifconfig_re0_2100="inet 10.212.100.14 netmask 255.255.252.0"
ifconfig_bridge0="addm re0.2100 up"
defaultrouter="10.212.100.254"

Is the order wrong?


----------



## SirDice (Oct 24, 2019)

kaschei said:


> Is the order wrong?


Order in rc.conf is irrelevant. 

Replace this:

```
ifconfig_bridge0="addm re0.2100 up"
```
With this:

```
autobridge_interfaces="bridge0"
autobridge_bridge0="re0.2100"
```


----------



## kaschei (Oct 24, 2019)

Sadly that didn't work either.
rc.conf:

vlans_re0="2100"
ifconfig_re0="up"
ifconfig_re0_2100="inet 10.212.100.14 netmask 255.255.252.0"
autobridge_interfaces="bridge0"
autobridge_bridge0="re0.2100"
defaultrouter="10.212.100.254"

I still need to manually enter: 
ifconfig bridge0 addm re0.2100 up


----------



## tommiie (Dec 6, 2019)

Did you already fix this issue?


----------



## kaschei (Dec 17, 2019)

Sadly no. Another problem is that if I put a vm in another VLAN then that won't work either


----------



## kaschei (Jul 22, 2021)

I started to look at this problem yesterday again and now I finally got it working like I wanted. First I had to set all the vlan on the sw to tagged and treat the re0 as an uplink.
The server runs several vm's that i manage with vm-bhyve. The main problem was that my vm's on the same vlan as the host did not work on that net. My rc.conf got a little simpler:

vlans_re0="2100"
ifconfig_re0="up"
ifconfig_re0_2100="inet 10.212.100.14 netmask 255.255.252.0"
defaultrouter="10.212.100.1"

To get the vm's to access the same vlan as the host I only had to add the re0.2100 to the vm bridge:
vm sw create public

The bridge got the name vm-public  (bridge0). 

ifconfig vm-public addm re0.2100 up

and it worked 

The rest of the vlan net was straigth forward
vm sw create adm-net
vm sw vlan adm-net 200
vm sw add adm-net re0


----------

