Network bridge

A network bridge is one of the possible ways to connect a QEMU Guest system to a real network. Bridging allows you to:

Bridging is one of the most powerful ways to connect a QEMU guest to a network, but it also has disadvantages:

Linux

Setting up a bridge under Linux in general is described for example in the various Linux-bridging-Howtos, like

Before trying the below please understand your host's connectivity will be severed during the initial steps. Your kernel must support bridging. Most wireless interfaces will not allow you to bridge with them (see http://linux-net.osdl.org/index.php/Bridge for more information).

The basic steps to set up a bridge for linux host are like this:

brctl addbr br0 
ifconfig eth0 0.0.0.0 promisc up
brctl addif br0 eth0
#!/bin/sh
sudo /sbin/ifconfig $1 0.0.0.0 promisc up
sudo /usr/sbin/brctl addif br0 $1

Make sure your /etc/qemu-ifup script is executable. If not, add executable attribute to it: #chmod +x /etc/qemu-ifup

sudo chmod 666 /dev/net/tun
qemu ... -net nic,vlan=0 -net tap,vlan=0

Some suggestions and notes for bridging under linux:

auto br0 
iface br0 inet static 
address 192.168.0.2 
netmask 255.255.255.0
network 192.168.0.0 
gateway 192.168.0.1 
bridge_ports eth0 
bridge_stp off 
bridge_maxwait 5
# referenced from http://qemu-forum.ipi.fi/viewtopic.php?t=374

FreeBSD

Setting up a bridge under FreeBSD is described in the FreeBSD Handbook: http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/network-bridging.html.

The basic steps to set up a bridge for FreeBSD hosts are:

#!/bin/sh
ifconfig ${1} 0.0.0.0
/sbin/kldload bridge
/sbin/sysctl net.link.ether.bridge_cfg=rl0,tap0
/sbin/sysctl net.link.ether.bridge.enable=1

If you have more than one virtual host, add the relative tap interfaces to the second line above and pay attention that the virtual hosts have ethernet cards with different MAC addresses.

Windows

The basic steps to set up a bridge for windows host can be found here:

NOTE: In some cases, if creating a bridge between a wireless adapter and the TAP adapter, it may be necessary to force the wireless network adapter to promiscuous mode. See this Microsoft Knowledge Base article: http://support.microsoft.com/kb/302348/en-us



bridge (last edited 2008-08-24 00:46:48 by 75-120-55-45)