6.5.1.2 Bridging on openSUSE hosts
The following instructions explain how to create bridge on openSUSE. Note that bridging
on openSUSE hosts may not work properly if you are using NetworkManager to
manage your network connections. To create a bridge on a recent openSUSE host, you
must first install the bridge utilities (bridge-utils) package. If you are working
from the command line this can be done as follows:
sudo /sbin/yast -i bridge-utils
Then you must create a text file describing the bridge to be created. The name of the
file must correspond to the name of the bridge you wish to create. To create the bridge
br0, you should call the file /etc/sysconfig/network/ifcfg-br0. Below we
have given an example of a file which creates a bridge including the network device
eth0, obtains an IP address by DHCP (through the network device) and is started
automatically when openSUSE starts. You will probably want to adjust this to match
your networking requirements.
66
6 Virtual networking
BOOTPROTO=’dhcp’
NETMASK=’255.255.255.0’
STARTMODE=’auto’
USERCONTROL=’no’
DHCLIENT_TIMEOUT=30
BRIDGE=’yes’
BRIDGE_PORTS=’eth0’
For this example to work, you will also need to change the configuration for
the network interface eth0 to a static IP address of 0.0.0.0, as openSUSE does
not do this automatically when the interface is added to the bridge. You can do
this using the graphical interface or by changing the following settings in the file
/etc/sysconfig/network/ifcfg-eth-xx:xx:xx:xx:xx:xx, where the last
part should be replaced with the hardware address of the network card.
BOOTPROTO=’static’
IPADDR=’0.0.0.0’
You can activate the bridge immediately after creating it with the command:
sudo /sbin/ifdown eth0
sudo /sbin/ifup br0
The bridge will be activated automatically from now on when the host is restarted.
Now, to create a permanent host interface called vbox0 (all host interfaces created
in this way must be called vbox followed by a number) and add it to the network
bridge created above, use the following command (see chapter 6.5.1.5, Host Interface
Networking utilities for Linux, page 69 for more details):
sudo VBoxAddIF vbox0 <user> br0
Replace <user> with the name of the user who is supposed to be able to use the
new interface.
To tell VirtualBox to use this interface (vbox0) for a virtual machine, select the
VM in the main window, configure one of its network adaptors to use Host Interface
Networking (using “Settings”, “Network”, “Attached to”) and enter “vbox0” 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 vbox0