Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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:




Here's an image that explains better my situation:

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

Thanks in advance

share|improve this question

closed as off-topic by Michael Hampton Jan 30 '14 at 13:26

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must demonstrate a minimal understanding of the problem being solved. Try including attempted solutions, why they didn't work, and the expected results. See How can I ask better questions on Server Fault? for further guidance." – Michael Hampton
If this question can be reworded to fit the rules in the help center, please edit the question.

What happened when you built the machines and gave them an IP address ? –  Iain Jan 29 '14 at 8:18
I've tried to assign an ip to a guest, but the connection didn't work and so i've posted on this forum looking for an help :) –  Tinez Ridan Jan 29 '14 at 13:40… –  Iain Jan 29 '14 at 13:43
What have you done so far? Your question does not indicate that you have actually done anything. –  Michael Hampton Jan 30 '14 at 13:26

2 Answers 2

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:

share|improve this answer
thanks for your link, can you show me how to set a single bridge for multiple ip? In your example there's only one. –  Tinez Ridan Jan 29 '14 at 13:42
which KVM lib are you using? you have to generate one bridge like shown in the link. Just tell the KVMs to use this bridge instead of the eth0. You don't have to generate more bridges. I am generating my vms like this: 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 All the VMs are using br0. The kernel is automatic generating the tap devices (ifconfig). –  peterus Jan 29 '14 at 14:22
I've KVM libvirt qemu and I've already installed 3 guests. With one bridge on eth0 is it possible to assign a separate public ip to each guest? I need to assign the IPs i've mentioned in the first post. –  Tinez Ridan Jan 29 '14 at 19:33
A way to put a static IP on a Server is posted in the answer. Just edit all the files in the VMs and put the corresponding IPs. Don't forget to put the correct DNS server. –  peterus Jan 30 '14 at 8:35

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.

share|improve this answer
Is it possible to use a network bridge on eth0? –  Tinez Ridan Jan 29 '14 at 9:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.