- 论坛徽章:
- 0
|
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
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/38576/showart_1719701.html |
|