Create a Bridged Interface in Ubuntu

Create a Bridged Interface in Ubuntu

Linux-KVM and Linux Containers both require a bridged interface so that it can be shared with the guests.  This can also be useful if you want to share a network configuration between a wireless card and a wired card (though I will not be going into this particular configuration).  Configuring a bridge is a pretty straight forward process.

# apt-get install bridge-utils

# cat /etc/network/interfaces
## This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.200
netmask 255.255.255.0
gateway 192.168.0.1

auto eth1
iface eth1 inet manual

auto br0
iface br0 inet static
address 192.168.0.201
netmask 255.255.255.0
gateway 192.168.0.1
bridge_ports eth1
bridge_stp off
bridge_maxwait 0
bridge_fd 0

As you can see above I have eth0 configured as a standard interface, while eth1 is initialized but not configured.  The configuration actually lives on br0, and bridge_ports defines the member as eth1.

Also you can use brctl to display information on your bridge(s).  After you have created your bridge you will be able to see your bridge.

# brctl show
bridge name    bridge id        STP enabled    interfaces
br0        8000.002219c41fc5    no        eth1

Although once you start adding machines which are using the bridge you will see additional interfaces show up under the appropriate bridge interface column.

# brctl show
bridge name    bridge id        STP enabled    interfaces
br0        8000.002219c41fc5    no        eth1
vnet0
vnet1

Also it is important to note that if you try and configure multiple interfaces on the same bridge connected to the same network, you can end up causing loops and disabling your network traffic.  This could be fixed by setting bridge_stp on however I am not positive and I have not tested that.  Additionally I have also tried to create a bond and then bridge the bond (in order to increase available throughput to the guests).  I have been able to get it to successfully work on the host level, but the guests cannot see anything on the network.  If I am successful in this attempt I will post an update.  If you are able to do so please post in the comments and I would be glad to update my post with your credited information.