virtualbox ose de host interface ayarı

We have already discussed how to install virtualbox and create virtual machines in ubuntu.This tutorial will explain How to set up host interface networking for VirtualBox on Ubuntu.

To start, NAT is by far the easiest way to get your guests connected to the interweb, but you may want to use the guests as servers. For this you need Host Networking.

To configure Host Networking you need to configure network bridging, you basically go through four steps on the host machine

* Install necessary packages

* Declare bridge and real network interface you add to it

* Declare virtual interfaces

* Set permissions on /dev/net/tun

Preparing Your system

You need to install the following packages

sudo apt-get install uml-utilities bridge-utils

Now you need to take the backup of your networking file using the following command

sudo cp /etc/network/interfaces /etc/network/interfaces.backup

You have to edit /etc/network/interfaces on the host machine to declare the bridge, this procedure is slightly different if your host use static or dynamic IP.

sudo gedit /etc/network/interfaces

If you have Dynamic IP, on the host machine:

auto eth0
iface eth0 inet manual

auto br0
iface br0 inet dhcp
bridge_ports eth0 vbox0

# The loopback network interface
auto lo
iface lo inet loopback

“eth0″ is the name of your interface, it can be different depending on your machine.

“br0″ is an arbitrary name for the bridge.

“vbox0″ is an arbitrary name for the device VirtualBox will use, if you want more devices, you just add then like:

bridge_ports eth0 vbox0 vbox1 vbox2 vbox3 vbox4 and so on.

If you are using Static IP addresses modify the interfaces like this:

auto eth0
iface eth0 inet manual

auto br0
iface br0 inet static
bridge_ports eth0 vbox0 vbox1

# The loopback network interface
auto lo
iface lo inet loopback

Replace with your IP, with your netmask and with your gateway. If you are using static IP addresses for eth0, eth1, etc; you will need to configure the br0 interface using the same settings! Otherwise your system will request an IP address via DHCP. You may add as many vbox# interfaces as you wish as long as they are also declared in /etc/vbox/interfaces; keep reading for details.

Save and exit the file.

You need to restart networking for the changes to take effect using the following command

sudo /etc/init.d/networking restart

Declare virtual interfaces in VirtualBox network file

To declare the virtual interfaces used by VirtualBox you need to edit /etc/vbox/interfaces on the host machine

sudo gedit /etc/vbox/interfaces

# Each line should be of the format :
#interface name user name [bridge]
vbox0 your user name br0
vbox1 your user name br0

Where “vbox#” is an arbitrary name. You may declare here as many virtual interfaces as you wish, as long as they have been properly declared in /etc/network/interfaces. In this specific article, we declared two vbox interfaces in /etc/network/interfaces, then finished setting them up in /etc/vbox/interfaces.

To take the modifications into account, restart the VirtualBox host networking script. If you installed VirtualBox OSE

sudo /etc/init.d/virtualbox-ose restart

If you installed the pre-compiled proprietary version

sudo /etc/init.d/vboxnet restart

The virtual interfaces are now created and added to the bridge.

That’s it! Now the different scripts will take care of cleanly create/configure/remove bridges and virtual interfaces when you boot and shut your system down.

Set permissions on /dev/net/tun

You need to have read/write permissions on the file /dev/net/tun to be able to use the bridge, to set permissions

sudo chown root:vboxusers /dev/net/tun

sudo chmod g+rw /dev/net/tun

This file is created with the default permissions every time the system restarts, to make the new permissions permanent you have to edit the file /etc/udev/rules.d/20-names.rules and change

KERNEL==”tun”, NAME=”net/%k”


KERNEL==”tun”, NAME=”net/%k”, GROUP=”vboxusers”, MODE=”0660″

Configure networking in VirtualBox

Once you have everything ready, you can start the VirtualBox management interface on the host machine, configure the network of your virtual machine, and by selecting “host networking”, enter the name of one of the virtual adapter you have configured. Start your virtual machine, it gets a network card presented, that you can set up as you wish (static IP address, DHCP) using the network configuration tools inside the virtual machine.