VirtualBox on FreeBSD cheat sheet

From ZS64
Revision as of 16:22, 16 April 2013 by Stefan Bethke (talk | contribs)
Jump to navigationJump to search

Network configuration with host bridge and bridged guest networking

It appears that there is a problem with bridged guest networking when the interface you want to bridge to on the host is an if_bridge(4) interface. It doesn't seem to work with either the bridge interface, a physical interface or a vlan(4) interface.

What does work is to use a tap(4) interface for the VM. Unfortunately, VirtualBox requires exclusive use of the tap interface per VM, so you need to set up one for each VM.

Add all the required tap(4) interfaces to rc.conf(5):

cloned_interfaces="bridge0 tap0 tap1"
ifconfig_bridge0="ether 02:00:00:00:00:01 addm tap0 addm tap1 addm em0"

Add these two lines to sysctl.conf(5):

The first enables non-root processes to open the tap interface, the seconds ifconfig up's the interface when the tap device is opened.

Patch for proper handling of VNC on IPv6-enabled machines

PR #174976 has a patch to enable proper configuration of libvncserver when it's compiled with IPv6 support; the stock VirtualBox does not properly deal with this case, and leaves the IPv6 port number set to it's default value of 5900. This in turn means that you can only enable VNC on one of the VMs, as each subsequent one will fail to start up.

The following variables influence the selection of addresses and port numbers:

$ VBoxManage modifyvm Ubuntu --vrdeport 5902
$ VBoxManage modifyvm Ubuntu --vrdeproperty VNCPort4=5902
$ VBoxManage modifyvm Ubuntu --vrdeproperty VNCPort6=5902
$ VBoxManage modifyvm Ubuntu --vrdeproperty VNCAddress4=
$ VBoxManage modifyvm Ubuntu --vrdeproperty VNCAddress6=::

Both VNCPort4 or VNCPort6 default to the port number set by --vrdeport; if that is unset or at it's default value of 3389, the extension will try to automatically determine an available port number when the VM start.

VNCAddress4 and VNCAddrees6 default to INADDR_ANY and IN6ADDR_ANY_INIT, respectively, so libvncserver will listen on all host addresses.

See VBoxVNC.cpp source code for details.