I have been looking for a way to enabling network inside virtualbox so that I can access it from anywhere thus being able to run various services inside virtual environment, trying out anything without any worries.
Here’s a simple how-to borrowed from archlinux wiki
Install bridge utils for creating bridge and uml_utilities for creating a tun device
pacman -S bridge-utils uml_utilities
Open the file /etc/udev/rules.d/60-vboxdrv.rules and add the following line to it
KERNEL==”tun”, OWNER=”root”, GROUP=”vboxusers”, MODE=”0660″
Then type the following command to load the tun module
modprobe tun
Now, let’s setup a bridge device to bridge network from your physical network interface to the virtual one
Create a bridge interface
brctl addbr br0
Set your interface in promiscous mode so it can accept packets from any interface
ifconfig <interface name> 0.0.0.0 promisc
Now, bridge the bridge interface with the real network interface
brctl addif br0 <interface name>
Now set the bridge interface to acquire IP address as your physical network interface would. eg if eth0 is your network interface and it acquires IP via DHCP then
dhclient br0
And finally add virtualbox host interface
VBoxAddIF vbox0 <VirtualBox user> br0
Now start VirtualBox and go to network settings. Select network interface as ‘host networking’ and interface device as ‘vbox0’.
Now you need to give an unused IP address in your IP range of the internet gateway. If you cannot provide that due to some reason then what you can do is create a virtual interface say eth0:0 then bind bridge network to that interface and setup NATing to pass packets between virtualbox and external network.
Comentários