Creating a network bridge on the host
Install the bridge-utils package:
sudo apt-get install bridge-utils
We are going to change the network configuration1. To do it properly, you should first stop networking2:
sudo invoke-rc.d networking stop
If you are on a remote connection, and so cannot stop networking, go ahead with the following commands, and use sudo invoke-rc.d networking restart at the end. If you make a mistake, though, it won't come back up.
To set up a bridge interface, edit /etc/network/interfaces and either comment or replace the existing config with (replace with the values foryour network):
auto lo iface lo inet loopback auto eth0 iface eth0 inet manual auto br0 iface br0 inet static address 192.168.0.10 network 192.168.0.0 netmask 255.255.255.0 broadcast 192.168.0.255 gateway 192.168.0.1 bridge_ports eth0 bridge_stp off bridge_fd 0 bridge_maxwait 0
or to use DHCP
auto lo iface lo inet loopback auto eth0 iface eth0 inet manual auto br0 iface br0 inet dhcp bridge_ports eth0 bridge_stp off bridge_fd 0 bridge_maxwait 0
This will create a virtual interface br0.
Now restart networking:
sudo /etc/init.d/networking restart
If your VM host "freezes" for a few seconds after starting or stopping a KVM guest when using bridged networking, it is because a Linux bridge will take the hardware address of the lowest numbered interface out of all of the connected interface. To work around this, add the following to your bridge configuration:
post-up ip link set br0 address f4:6d:04:08:f1:5f
and replace f4:6d:04:08:f1:5f with the hardware address of a physical ethernet adapter which will always be part of the bridge.