Virtulisation :: Centos :: KVM

Having looked at and got working Xen, both as NAT and as Bridge.

 

Now for VKM

  1. Created server and installed packages as I wanted.
  2. Copied my xp-sp3 oem install cd.
  3. Got my valid XP keys ready.
  4. Create my xp vm, but it is getting it's ip address from the "default" network settings, /etc/libvirt/qwmu/networks/default.xml
  5. I want my xp VM to get's ip address from my networks dhcp server (which later will be this server)

The configuration I am looking for

My Local
LAN
switch

My Firewall
&
Virt Server

Switch The Internet
192.168.x.x
255.255.255.0
<==> eth0
192.168.x.254
255.255.255.0
eth1
123.123.123.123
255.255.255.0
<==>
xp VM 1
192.168.x.x
xp VM 2
192.168.x.x
xp VM 3
192.168.x.x

CentOS VM
192.168.x.253

This page got me going at first:
http://www.cyberciti.biz/faq/rhel-linux-kvm-virtualization-bridged-networking-with-libvirt/

Most of what follows is a plagiarisation from them.

Trun off NetworkManager (mine is off by default)

chkconfig NetworkManager off
chkconfig network on
service NetworkManager stop
service network start

etc/sysconfig/network

emacs /etc/sysconfig/networks

NETWORKING=yes
FORWARD_IPV4=true
HOSTNAME=mail.me.co.nz
DOMAINNAME=me.co.nz
GATEWAY=br1

/etc/sysconfig/network-scripts/ifcfg-eth0

emacs /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
#IPADDR= }
#NETMASK= } These four lines
#NETWORK= } no longer needed
#BROADCAST= }
ONBOOT=yes
BOOTPROTO=none
BRIDGE=br0
HWADDR=E8:9A:8F:22:88:A9
USERCTL=no




Your mac address, HWADDR will be different.

/etc/sysconfig/network-scripts/ifcfg-br0

emacs /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.x.1
NETMASK=255.255.255.0
DELAY=0




Your IPADDR will be different, obviosly with out an x.
NOTE Bridge must be spelt with a capital B

/etc/sysconfig/network-scripts/ifcfg-eth1

emacs /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth0
#IPADDR= }
#NETMASK= } These four lines
#NETWORK= } no longer needed
#BROADCAST= }
ONBOOT=yes
BOOTPROTO=none
BRIDGE=br1
HWADDR=E8:9A:8F:22:88:A98
USERCTL=no




Your mac address, HWADDR will be different.

/etc/sysconfig/network-scripts/ifcfg-br1

emacs /etc/sysconfig/network-scripts/ifcfg-br1
DEVICE=br1
TYPE=Bridge
BOOTPROTO=static
ONBOOT=yes
IPADDR=123.123.123.123
NETMASK=255.255.255.0
DELAY=0



Now

service network restart

brctl show

bridge name bridge id STP enabled interfaces
br0 8000.0030488e31ac no eth0
br1 8000.0030488e31ad no eth1
virbr0 8000.000000000000 yes

To check all is well:

ip addr show br0
ip addr show br1
ip route
ping cyberciti.biz
host google.com

This got me a nice ways along, but when I started mu xp VM, it is still using the NAT settings.
This is where this page set me to the next step.
http://wiki.libvirt.org/page/Networking

The extra things I did from this pages:

 # cat >> /etc/sysctl.conf <<EOF
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0
EOF
# sysctl -p /etc/sysctl.conf

Here are some iptables rules that I did not use.

# echo "-I FORWARD -m physdev --physdev-is-bridged -j ACCEPT" > /etc/sysconfig/iptables-forward-bridged
# lokkit --custom-rules=ipv4:filter:/etc/sysconfig/iptables-forward-bridged
# service libvirtd reload

Now to edit the Guest configuration for my xp VM 1.

This is found at /etc/libvirt/qemu/VM-xp01.xml (in my case)

I needed to change the section on networking from:

<interface type='network'>
<mac address='54:52:00:32:2b:d6'/>
<source network='default'/>
</interface>

to

    <interface type='bridge'>
<mac address='54:52:00:32:2b:d6'/>
<source bridge='br0'/>
</interface>

Just to make sure:

/etc/init.d/libvirtd restart
and
/etc/init.d/libvirt-guests restart

Restart the Virtual Machine Manager

Restart the xp VM

In my case it was not getting it's ip address from my dhcp server I could ping into my network, I could not ping this VM machine, but I believe that this is to be expected. I could RDT in and have this VM as I really wanted it.

Creating a Clone

Having create an XP machine with all the settings, programs and updates, I now want to create 4 copies for 4 different people to RDT in. Make sure you have licenses to re-register these clones with valid software.

virt-clone -o VM-old -n VM-new -f /home/VM/images/new.img

I made sure first the my VM was shutdown, but reading the help file it would appear that this command will first shut down the existing VM if it is running. My /home directory is about 1T in size so I have all my images and isos in this directory, VM. VM is not a user on my system, I am just using /home as a convenient location to hold it.

 

 

Edit /etc/sysconfig/network, enter: