Debian and KVM virtual machine
Tags : bridge, Debian, kvm, virtualisation
I want to play with my brand new Intel Q6600 Core2Quad an Xen 3.1. But IDE chip vt8237s is not supported by 2.6.18 linux kernel. There is a hack to correct this but it's quite ugly.
So why not try KVM ? Amazing !
First, install userspace things :
% apt-get install kvm qemu
Load Intel VT support :
% modprobe kvm-intel
Create a new disc image in CoW (Copy on Write) mode :
% qemu-img create disk.cow 5G
Start KVM with 512MB Ram and Debian 4.0 install CD :
% kvm -hda disk.cow -cdrom /path/debian-40r1-i386-businesscard.iso -boot d -m 512
Just install minimal Debian, and start again without CD option :
% kvm -hda disk.cow -m 512
Basic configuration is automatic. Guest system (not so guest, it's KVM) get an IP address by DHCP. That's KVM/QEMU default userspace routing. I don't like it.
I just have one NIC and i must play with TUN/TAP virtual NIC to get ethernet bridge to work.
We need tunctl from uml-utilities package :
% apt-get install uml-utilities
Stop networking stuff :
% /etc/init.d/network stop
And change /etc/network/interfaces like this :
auto lo eth1 tap10 br0 iface lo inet loopback iface tap10 inet manual pre-up tunctl -b -u denis -t tap10 pre-up ifconfig tap10 up post-down tunctl -d tap10 iface br0 inet static bridge_ports eth1 tap10 bridge_maxwait 0 address 192.168.0.1 netmask 255.255.255.0 network 192.168.0.0 broadcast 192.168.0.255 gateway 192.168.0.10 iface eth1 inet manual
Configuring loopback then eth1. Then create tap10 (tap0 used with OpenVPN here) and we bridge eth1 and tap10 and give an IP addresse to the bridge interface. eth1 and tap10 are now physically connected to a virtual hub. Now start kvm with :
% kvm -hda disk.cow -m 512 -net nic -net tap,ifname=tap10
In the guest /etc/network/interfaces we have :
iface eth0 inet static address 192.168.0.200 netmask 255.255.255.0 network 192.168.0.0 broadcast 192.168.0.255 gateway 192.168.0.10
Done !