Ubuntu – KVM – Bridged interface with DHCP for main interface

kvm-virtualizationUbuntuvirtualization

I'm setting up an Ubuntu 10.04 server to run KVM.
I need the virtual machines to have bridged networking, since they will be part of my main LAN. In addition, eth0 (the main network interface on the server) is using DHCP to get a static IP from the DHCP server (that way, I have a central point to change the IPs of my servers).

When trying to add a br0 interface (as described here http://wiki.libvirt.org/page/Networking#Bridged_networking_.28aka_.22shared_physical_device.22.29) I changed my /etc/network/interfaces as follows:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

# The bridge network interface, used by kvm
auto br0
iface br0 inet manual
bridge_ports eth0
bridge_stp yes
bridge_fd 0
bridge_maxwait 0

I also added the following lines to sysctl.conf:

net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0

As soon as I reboot the server, I loose connectivity to eth0 (outgoing and ingoing).

What's wrong with this configuration? What's the recommended setup?

Best Answer

The main difference I see is that my config (also on Ubuntu 10.04) -- which thankfully works -- does not assign IP, etc directly to the eth0 interface, but rather to the br0 interface.

Note that in my config, the guests are configured to use DHCP and that works with the /etc/network/interfaces as below:

# The primary network interface
auto eth0
iface eth0 inet manual 

# bridge interface for kvm
auto br0
iface br0 inet static
        address 192.168.1.254
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.1.255
        gateway 192.168.1.1
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 4.2.2.1 8.8.8.8
        dns-search mycompany.com
        bridge_ports eth0
        bridge_fd 9
        bridge_hello 2
        bridge_maxage 12
        bridge_stp off

I'm pretty sure you could just change the part about ' iface br0 inet static ' to dhcp and remove the address, netmask, network, gateway, etc. stuff.

I didn't have to mess with the sysctl.conf settings... at least yet.