[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Geloest] Re: Bridging klappt nicht (KVM)



Hallo Uwe,

Also, jetzt klappt es tatsächlich. Ich weiß leider nicht genau warum es vorher nicht ging, wahrscheinlich hatte ich das Prinzip einfach nicht gut genug verstanden.

Um den Thread rund zu machen, beschreibe ich hier mal meine Vorgehensweise um eine virtuelle maschine mit debian testing auf einen debian stable aufzusetzen:

backports-quellen in /etc/apt/sources.list eintragen:

deb http://www.backports.org/debian etch-backports main contrib non-free

kernel und kvm pakete installieren:

aptitude -t etch-backports install linux-image-2.6.22-4-amd64 kvm-modules-2.6.22-4-amd64 kvm qemu

neuen kernel booten

mit modconf das kvm-modul (kvm-amd, sektion misc) in den kernel einbinden.

Datei für das Image für die virtuelle Maschine (VM) erzeugen:

qemu-img create -f qcow testing.qcow.img 15G

Zum Testen der Installation Knoppix ins cdrom und:

kvm -m 512 -cdrom /dev/cdrom -boot d

Ich möchte bridged networking für die virtuellen maschinen. Also erstmal die bridge vorbereiten. Dazu das aktuelle netzwerk device (bei mir eth1) in /etc/network/interfaces auskommentieren und eine bridge br0 einfügen.

# 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 br0

iface lo inet loopback

# The primary network interface
#allow-hotplug eth1
#iface eth1 inet dhcp

# Bridge
iface br0 inet dhcp
        bridge_ports eth1
        bridge_maxwait 5

Jetzt das Netzwerk neu starten:

/etc/init.d/network restart

Auf dem Host-System sollte das Netzwerk jetzt funktionieren:

ping ftp.suse.de

Jede meiner VM bekommt ein eigenes Startskript wie dieses (startkvm.sh):

#!/bin/sh
# script to manage tap interface allocation
# for linux kernels >= 2.6.18
# based upon http://calamari.reverse-dns.net:980/cgi-bin/moin.cgi/FrequentlyAskedQuestions#head-2511814cb92c14dbe1480089c04f83c281117a86
#
# Any command line arguments will be passed
# to kvm "as is"

# set up a tap interface for kvm

# USERID - uid kvm is being run under.
USERID=`whoami`
# we need uml-utilities for the next line
# as well als the module "tun" (check with lsmod) and
# appropriate sudo-capabilities (
# create a tap-interface for kvm
iface=`sudo tunctl -b -u $USERID`

#Add the newly created interface to the bridge
#bridge br0 must exist -> place something like
# 	iface br0 inet dhcp
#		bridge_ports eth1
# into your /etc/network/interfaces
# we need appropriate sudo-rights for this
sudo brctl addif br0 $iface

# Enable interface (again we need appropriate sudo-rights here)
sudo ifconfig $iface up

# specify which NIC to use - see qemu.org for others
# I don't use this at the moment
# model=ne2k_pci
# model=rtl8139
# model=ne2k_isa

# specify the MAC-address the NIC in the virtual machine
# should get. Otherwise a random mac is chosen which might
# confuse the guests udev.
# Modify this for every new virtual machine
mac="00:ff:87:b3:87:e2"

# start kvm (make sure the current user belongs to the kvm group
# or use the -no-kvm flag
# kvm might complain that it can not assign the interface to the bridge,
# but since we did that already everything should just work fine
echo Starting kvm...
kvm -m 512 -hda testing.qcow.img -no-acpi -net nic,macaddr=$mac -net tap,vlan=0,ifname=$iface $@

# kvm stopped so should be the interface
sudo ifconfig $iface down
sudo tunctl -d $iface &> /dev/null

Dieses Startskript benötigt noch einige Vorbereitungen:

sudo-Rechte mittels visudo für die Gruppe kvm einrichten (folgende Zeilen einfügen):

# Gruppe kvm darf Bridge br0 fuer KVM aufsetzen (MUE 18.04.08)
%kvm ALL=NOPASSWD:/usr/sbin/tunctl
%kvm ALL=NOPASSWD:/usr/sbin/brctl addif br0 tap*
%kvm ALL=NOPASSWD:/sbin/ifconfig tap* up
%kvm ALL=NOPASSWD:/sbin/ifconfig tap* down

Alle User, die kvm-Maschinen benutzen, zur Gruppe kvm hinzufügen:

adduser werauchimmer kvm

Die virtuelle Maschine mit Installations-CD booten (als normaler user):

startkvm.sh -cdrom /srv/iso/Debian_4.0r2_netinstall.iso -boot d

Und voila! DHCP _sollte_ funktionieren (und bei mir tut es das ja jetzt auch, jipiee).

Danke für die Tipps,

	Arnd
--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Arnd Münzebrock                                    Arnd@nurfuerspam.de
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Seit ich das Alphabet kenne, versuche ich es zu benutzen...


Reply to: