Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3815867
  • 博文数量: 197
  • 博客积分: 10086
  • 博客等级: 上将
  • 技术积分: 5145
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-13 10:50
文章分类

全部博文(197)

文章存档

2011年(2)

2009年(30)

2008年(165)

我的朋友

分类: LINUX

2008-12-14 14:49:11

To set up a permanent host interface on a Debian or Ubuntu host, follow these steps:

1. On modern Debian and Ubuntu based hosts, you must first install the UserMode Linux utilities package (uml-utilities), which contains tools to create TAP interfaces, as well as the bridge utilities (bridge-utils). package. You can do this from the command line using

sudo apt-get install uml-utilities

sudo apt-get install bridge-utils

In order for VirtualBox to be able to access the interface, the user who will be running the virtual machine must be added to the group uml-net, for example with the following command (replace vboxuser with your user name):

sudo gpasswd -a vboxuser uml-net

You may have to log out and log in again for the change to take effect.

2. To describe the TAP interface to your Debian or Ubuntu system, add an entry to the file /etc/network/interfaces. This names the the interface and must also specify the user who will be running the virtual machine using the interface. The following sample entry creates the interface tap0 for the user vboxuser (again, replace with your user name):

auto tap0

iface tap0 inet manual

up ifconfig $IFACE 0.0.0.0 up

down ifconfig $IFACE down

tunctl_user vboxuser

You will probably want to change the entry based on your networking needs. On the host, you will find more documentation in these files:

a) /usr/share/doc/uml-utilities/README.Debian and

b) /usr/share/doc/ifupdown/examples/network-interfaces.gz.

3. The first time it is used, activate the new interface and the bridge with these two commands:

sudo /sbin/ifup tap0

sudo /sbin/ifup br0

This is only needed once, however; the next time the host is restarted, the interface and the bridge should be activated automatically.

4. Another entry must be added to the file /etc/network/interfaces to describe the bridge. The following sample entry creates a bridge called br0, adds to it all ethernet interfaces on the host as well as the TAP interface created above and tells it to obtain an IP address using DHCP so that the host remains able to access the network.

auto br0

iface br0 inet dhcp

bridge_ports all tap0

Again, you will probably want to change this to suit your own networking needs. In particular, you may want to assign a static IP address to the bridge, or if you are using TAP interfaces created by VirtualBox (these are described later), you will want to remove tap0 from the last line. On the host, you will find more documentation in the files

a) /usr/share/doc/bridge-utilities/README.Debian.gz and

b) /usr/share/doc/ifupdown/examples/network-interfaces.gz.

5. To tell VirtualBox to use the interface, select the virtual machine which is to use it in the main window of the VirtualBox application, configure one of its network adaptors to use Host Interface Networking (using "Settings", "Network",“Attached to”) and enter “tap0” into the “Interface name” field. Alternatively, you can use the VBoxManage command line tool (in this example we are attaching the interface to the first network card of the virtual machine ("My VM"):

VBoxManage modifyvm "My VM" -hostifdev1 tap0

阅读(828) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~