2008年10月15日 星期三

Bridging VirtualBox 1.6.2 on Ubuntu 8.04.1

前言:VirtualBox 安裝完成後,網路的初始設定為 NAT 模式,如此的設定 guest 可上網但無法連線網路芳鄰,host 則無法上網。必須改為 Bridging 模式才可解決此問題,設定如下:

The steps I mentioned here is assumed that the host system is behind a router and the ip addresses are distributed by DHCP from the router.

Step 1 :

Install the required package for the bridged network on the host.

sudo apt-get install uml-utilities bridge-utils

Issue the following command to stop the network interface.

sudo invoke-rc.d networking stop

Edit the /etc/network/interfaces by the below command.

sudo nano /etc/network/interfaces

The content of the file should be like this. That is, append the line of 「auto br0」 and the rest to the end of /etc/network/interfaces. The codes are for bridging eth0 and you can change it as required.

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

auto br0
iface br0 inet dhcp
bridge_ports eth0
bridge_fd 9
bridge_hello 2
bridge_maxage 12
bridge_stp off

Restart the network interface.

sudo /etc/init.d/networking restart

Step 2 :

Still on the host. Issue the following commands.

sudo VBoxAddIF vbox0 `whoami` br0
VBoxManage modifyvm "My VM" -hostifdev1 vbox0
sudo chmod 0666 /dev/net/tun

* where 「My VM」 is the name of your guest (eg myself is 「WinXP」). The network interface should be Host Interface.

Make sure, at the GUI VirtualBox panel, select 「Network」, Select 「Host Interface」 at 「Attached to」 and fill in the blank to 「vbox0」 at 「Interface Name」.