Here's some background... I have my init scripts written to create the bridge interface (br0), add the actual physical interface (eth1) to the bridge, and obtain an IP address via DHCP at startup. I've also modified the udev rules to set the permissions of the /dev/net/tun device to 0666, and this has been verified by doing a ls -l /dev/net/. This all works fine and I end up with a working bridge interface (br0) and everything works fine on the host machine. I have installed (via emerge) virtualbox-bin and virtualbox-modules and I load the kernel module at boot time.
I have added my user (and the root user also) to the vboxusers group. I created the following scripts to create and destroy a tap interface:
vbox_up
Code: Select all
!#/bin/bash
#create the tap interface and make current user the owner
sudo /usr/sbin/tunctl –t $2 –u `whoami`
#bring it up unconfigured
sudo /sbin/ifconfig $2 up
#add the tap interface to the bridge (br0)
sudo /sbin/brctl addif br0 $2Code: Select all
!#/bin/bash
#remove the tap interface from the bridge (br0)
sudo /sbin/brctl delif br0 $2
#destroy the tap interface
sudo /usr/sbin/tunctl –d $2Code: Select all
%vboxusers ALL = NOPASSWD: /sbin/ifconfig, /sbin/brctl, /usr/bin/tunctlCode: Select all
chown root:vboxusers vbox_up vbox_down
chmod a+x vbox_up vbox_downWith the scripts working, I then changed Networking to 'Host Interface', typed 'vbox0' as the interface name, and added these scripts to the 'Startup Application' box (/usr/bin/vbox_up) and 'Terminate Application' box (/usr/bin/vbox_down). Now when VBox is started as root the tap interface is created and added to the bridge and works perfectly (I have connectivity in the WinXP guest and can ping back and forth between host and guest). When the VM is stopped the interface is destroyed - just as it should be. *However* when I start VBox as a non-root user and try to start the VM, I get the following error:
No tap interface is created and the VM won't start. It appears that VBox will only execute the scripts as root - not as the non-root user. As mentioned above, I can execute the scripts from the command line as a non-root user and they work fine, but not from VBox. I also tried hard coding the interface (vbox0) in the scripts and it still doesn't work as non-root.Failed to initialize Host Interface Networking.
VBox status code: -3100 (VERR_HOSTIF_INIT_FAILED).
Result Code: 0x80004005
Component: Console
Am I overlooking something here, maybe some special execution method or permission - something OS related, or am I doing something wrong with VBox? I don't understand why I can execute my scripts from the command line as a non-root user, but VBox only executes them when started as root.
I have successfully started the VM as the non-root user by the following sequence
- execute the vbox_up script from the command line (replacing $2 with vbox0)
start VBox from the command line
start the VM
Any ideas??
Thanks!