Tony's ramblings on Open Source Software, Life and Photography

kvm

Using Bridged Networking For KVM / QEMU (and how to install)

There's so many different HOWTO's on the Internet regarding using bridged networking for kvm virtual machines. Unfortunately most are completely out of date, wrong or just don't apply to Ubuntu's implementation.

Believe it or not, it's not very hard. KVM/QEMU will automatically create the "tap" interface (actually it names them vnetX) and will even create a new MAC address for it. All we have to do is put our primary ethernet adapter into promiscuous mode and create a bridge device.

Both steps are easily done by editing /etc/network/interfaces. No additional scripts are needed if you're using static IP addresses.

Here's an example setup for preparing the host machine. This assumes you have one physical card in the machine (eth0) and that you want to access your host machine using 192.168.1.2:

# The loopback network interface
auto lo
iface lo inet loopback

# Create our bridge interface using a static IP address on the network
auto br0
iface br0 inet static
        address 192.168.1.2
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.1.255
        gateway 192.168.1.1
        pre-up ifconfig eth0 down
        pre-up ifconfig eth0 0.0.0.0 promisc up
        pre-up brctl addbr br0
        pre-up brctl addif br0 eth0
        bridge_fd 9
        bridge_hello 2
        bridge_maxage 12
        bridge_stp off
  

Categories:

KVM and Windows XP Under Ubuntu 8.04 64 Bit

Setting up KVM for virtual machines in Ubuntu 8.04 is easy!

A few simple steps will get you up and running. First, install the packages with your favorite package manager, or at a console type:

sudo apt-get install kvm libvirt-bin virt-manager virt-viewer qemu

I also found I needed to add myself to the kvm group:

sudo adduser `id -un` kvm
sudo adduser `id -un` libvirtd


You must add yourself to libvirtd for networking to function :-)

Here's one of the few situations where rebooting linux is probably easier for most people than trying to manually start everything, so give her a boot and log back in.

Under your Applications menu in "System Tools" you'll find "Virtual Machine Manager". Connect to the qemu "localhost" setup that is already there by right clicking on it. After it says you are connected, click New at the bottom of the window to create a new virtual machine instance. Follow the wizard to configure your install.


Categories: