KVM On Ubuntu - KVM Logo

Installing and Running KVM on Ubuntu 14.04 Part 2

In part 1 of the series I covered basic machine set up and preparation. In this second part of the series about setting up KVM on Ubuntu 14.04 I cover setting up the network. Setting up the network can seem quite daunting but a basic KVM install doesn’t actually require much network set up.

UPDATE: There’s nothing wrong with the techniques discussed in this article but I now feel that a routed network is simpler to set up and manage so I recommend that set up and have described it here.

Configure the Network for KVM

As I mentioned in part 1 of this series I’m going to be a using a single interface on the host machine to connect to the network which will require setting an internal bridge on the host. The bridge will allow the various VM guests to have their own virtual network interfaces and IP addresses and, therefore, be directly addressable. The end set up I’m aiming for at the moment is designed to make my life as easy as possible. The host will be on one IP address, lets say and the guests will be on increments of that (e.g. The whole lot will be configured by DHCP which will be handled by my internet router.

Open your /etc/network/interfaces file. It will probably look something like this:

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp

Reconfigure it so that a bridge is defined and assigned an IP address via DHCP. Alternatively you could assign the machine a static IP address but remember to block out the IP in the DHCP server so it can’t accidentally be assigned to any other machine.

The end result should be something like this:

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet manual
auto br0
iface br0 inet dhcp
    pre-up ip link add br0 type bridge
    pre-up ip link set dev br0 address 02:0e:89:06:d9:0f
    pre-up ip link set eth0 master br0
    post-down ip link set eth0 nomaster
    post-down ip link delete br0
    bridge_stp off
    bridge_fd 0
    bridge_maxwait 0

Note that there is no need to install the deprecated bridge-utils package any more all the configuration can be done using the iproute2 “ip” command which is installed by default. As you can see it’s a little more involved but I think once you get used to the ip command you won’t go back. The last three commands simply stop the bridge from participating in spanning tree and should make it a little more efficient.

In part three of this series on installing KVM I’ll actually install KVM and start configuring it.

Read More