Virtualbox bridging with vlans

Hi. I've got an odd situation here on 8.2-STABLE with virtualbox-ose-4.0.4 and a guest built from the same /usr/obj. Upgraded to VirtualBox 4.0.8 (including rebuilding/reloading the kmod) with no change.

Host rc.conf:
Code:
vlans_bge0="100"
ifconfig_bge0="inet 10.0.0.1/24"
ifconfig_bge0_100="inet 192.168.0.1/24"
ifconfig_bge0_101=...
...

Everything works fine on the host. Bridge a VirtualBox guest though, and everything goes wrong. Bridged to bge0.100, the guest sends tagged packets (correct) but receives nothing (tcpdump -ni em0 on the guest shows nothing despite it being a noisy network) The host interface does go PROMISC as expected while the guest's running.

Bridge the guest to bge0 and tcpdump -eni em0 on the guest shows vlan100 traffic natively (incorrect - it should be .1q encapsulated now) but no other vlans. Outgoing traffic from the guest is not tagged (correct)

Even stranger is when I create a vlan interface on the guest, packets sent through that also come out untagged (should be double-tagged?), and there's no packets received on the guest's subinterface.

Previously with VLANs out of the equation, Virtualbox worked perfectly.

Any ideas?
 
Your VLAN interfaces aren't set up correctly. Contrary to what you might think ifconfig_bge0_100 doesn't refer to VLAN100.
 
I used to use cloned_interfaces and
Code:
ifconfig_vlan100="vlandev bge0 vlan 100 192.168.2.1/24"
but I recently re-read the rc.conf man page.

&quot said:
Code:
                 To create a vlan device named em0.101 on em0 with the vlan
                 tag 101 and the optional the IPv4 address 192.0.2.1/24:

                 vlans_em0="101"
                 ifconfig_em0_101="inet 192.0.2.1/24"

Is the man page wrong about this new syntax? It appears to work fine for me - the host can interact with all the vlans perfectly.
 
If you try something at layer2 in VirtualBox and you are sure the setup is correct, then try your settings on a real machine and not in VirtualBox. I had lots of problems trying to simulate a bridge of two virtual box FreeBSD guests (on an Apple OSX Host). The configuration worked ok in real settings. I don't know if this happens for all VirtualBox hosts, mine was OSX.
 
Looking into how VirtualBox does its bridging - via netgraph - it became apparent something on the FreeBSD-side was wrong. Netgraph uses a period for its path separator and was choking on the new-style interface naming.

This was discussed a few months ago on the freebsd-net mailing list, but nothing seems to have made it to -STABLE: http://www.mail-archive.com/freebsd-net@freebsd.org/msg35895.html

Reverting to an old-style configuration where I'm calling the vlan interfaces "vlan100" and so on appears to fix everything as far as bridging vlans to guests is concerned. Bridging (in VirtualBox) the parent NIC is still broken in the same strange way - something is untagging vlan100 frames before sending just them to the guest. Perhaps something in if_vlan or if_bge land is interfering with netgraph's access to the NIC?

This would appear to mean it's impossible to use a trunked configuration in a guest on FreeBSD, at least where the host is using vlans on a bge nic... :/
 
Eleven years later:

OP, you rock. The problem of bridging Virtualbox VM NICs to host VLAN interfaces is still a thing in FreeBSD 13.0-RELEASE and VirtualBox 6.1.26. I've been wrestling with this problem for years and despite multiple Google searches I didn't stumble across your solution until just now. Changing the names of the VLAN interfaces worked perfectly. Thank you for this.

(I'm so happy right now I made a forum account just to be able to post this.)

Bruce.
 
Back
Top