7

i've a CentOS 6.5 KVM Host with 3 KVM-Guest CentOS 6.5. Now I want to assign a public IP for the host and one public IP for each guest using a single network interface. My IPs (assigned by network administrator) are:

  1. 10.25.147.100
  2. 10.25.147.101
  3. 10.25.147.102
  4. 10.25.147.103

Mask: 255.255.254.0

Gateway 10.25.146.9

Here's an image that explains better my situation:

http://oi60.tinypic.com/w1tjl2.jpg

I'm a newbie with linux, so please help me :)

Thanks in advance

Michael Hampton
  • 252,907

2 Answers2

1

You can use a Bridge on the Host-Server. The other KVMs will use a static IP.

How to create a Bridge: Link. Now you just have to use the Bridge in your KVMs. If you use virsh with the argument --network=bridge:br0

To install a new VM with help from virsh, I am using this command:

virt-install --connect qemu:///system --name test_vm --ram 1024 --vcpus 2 --disk path=/vms/test_vm.img,size=10 \
             --network=bridge:br0 \
             --os-type=linux --graphics vnc,password=test --autostart --virt-type kvm

Special the 2. line is telling the simulator to use the bridge br0. The Linux-Kernel is automatically creating the tap devices for the bridge, you can check this with ifconfig.

A VM need's now a static IP. In CentOS you have to edit /etc/sysconfig/network-scripts/ifcfg-eth0:

DEVICE="eth0"
BOOTPROTO="none"
HWADDR=
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
UUID=
IPADDR=10.25.147.10*
NETMASK=255.255.254.0
DNS1=10.25.146.???
GATEWAY=10.25.146.9
peterus
  • 21
0

Your picture is wrong - you cannot assign IP addresses outside of the KVM hosts, but only inside in the KVM hosts.

If you want assign 3 IP address for 3 KVM machines, you have to use KVM switch and IP address assign in every KVM hosts (and only in the KVM hosts!). They will be communicate through software switch and you will see they under they're addresses.

Jan Marek
  • 2,230