LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
Password
Linux - Virtualization and Cloud This forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices



Reply
 
Search this Thread
Old 09-26-2010, 01:56 AM   #1
vzxen
Member
 
Registered: Jul 2010
Posts: 126

Rep: Reputation: 4
Assign IP to Guest VM in KVM


I have a server with 5 Public IPs.
I have installed CentOS as Host and KVM virtualization.
Creating a Guest is simple using virt-manager.

I wanted to know how to give one Public IP out of the 5 to a Guest VM.
In OpenVZ its pretty simple as you can use vzctl 101 --ipadd.

How to do this in KVM ?
 
Old 09-26-2010, 02:00 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
you don't do it in kvm, you do it within the guest operating system. KVM doesn't care about the IP addresses you're using and clearly has no way to reach inside the VM and configure it automagically, why should it? Just configure the guest appropriately like any other operating system install on a physical machine.
 
Old 09-26-2010, 07:52 AM   #3
vzxen
Member
 
Registered: Jul 2010
Posts: 126

Original Poster
Rep: Reputation: 4
You mean to configure /etc/sysconfig/network-scripts/ifcfg-eth0
I have done that and indeed it works as well.

But what if the user adds two IPs himself.
How will that be controlled ?
 
Old 09-26-2010, 06:25 PM   #4
Ramurd
Member
 
Registered: Mar 2009
Location: Rotterdam, the Netherlands
Distribution: Slackwarelinux
Posts: 555

Rep: Reputation: 75
either by bridging or setting up a vde lan (best way to go imo due to privileges)
 
Old 09-27-2010, 12:51 AM   #5
vzxen
Member
 
Registered: Jul 2010
Posts: 126

Original Poster
Rep: Reputation: 4
Is there any bridging guide ?
Also by "vde lan" you mean a virtual device right ?
 
Old 09-27-2010, 01:49 AM   #6
Ramurd
Member
 
Registered: Mar 2009
Location: Rotterdam, the Netherlands
Distribution: Slackwarelinux
Posts: 555

Rep: Reputation: 75
There are quite alot of bridging guides, essentially what you have to do on your host system is create a bridge device and attach it to your virtual machine using the tun/tap devices.

With vdelan I do not really mean virtual device, that's about eveything on a virtual machine ;-) I mean Virtual Distributed Ethernet. In short: a virtual switch. You can connect to that if you define your net device with if=vde (you also need a "real" interface, for which I use virtio)

you then get -net vlan=0,if=virtio,macaddr=01:23:45:67:89 -net vlan=0,if=vde

For that you only need one tap device, which you can create at boot time (doesn't really hurt) on your host. Adding dnsmasq and attach it to that device and you have a dynamic solution that offers near everything in this regard.

AlienBOB wrote some nice stuff about this. Although it is based on a Slackware host, I think you can pick some nice candies of knowledge out of it:
http://wiki.alienbase.nl/doku.php?id=slackware:vde
 
Old 09-27-2010, 03:33 AM   #7
vzxen
Member
 
Registered: Jul 2010
Posts: 126

Original Poster
Rep: Reputation: 4
Do the Virtual Machines get IPs like 10.0.0.x by default ?
Cant we use iptables to forward in this case ?
 
Old 09-28-2010, 01:13 AM   #8
Ramurd
Member
 
Registered: Mar 2009
Location: Rotterdam, the Netherlands
Distribution: Slackwarelinux
Posts: 555

Rep: Reputation: 75
There are no default IP numbers for the virtual machines; you define the addresses that should be assigned with dnsmasq. Then again: addresses like 10.x.x.x are good values for being safe to use internally.

You can use iptables to forward them indeed; addresses need only to be known to the host that forwards the ports.
 
Old 09-28-2010, 02:34 AM   #9
vzxen
Member
 
Registered: Jul 2010
Posts: 126

Original Poster
Rep: Reputation: 4
The following CentOS documentation mentions it does :
http://wiki.centos.org/HowTos/KVM#he...cf987d04f7fc96

Also in the bridging method, do I have to create a new bridge for each Virtual Machine ?
 
Old 09-28-2010, 05:14 AM   #10
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
no, you don't create a new bridge unless you want to, i.e. you have a different address space and requirements from it. I'm currently building a very bespoke kvm / qemu environment with about 14 bridges between 8 VM's, but in a simple environment you would often only have a single bridge, default, onto which all VM's would be hooked. if you're using virt-manager then there, as I understand it, a short coming in the network tpyes in that you can create routing bridges and nat bridges, but not transparent bridges, where your VM ip's would be in the same address space as the other physical machines in the environment. This can be created very easily on the machine though outside of virt-manager
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
KVM: Mouse under Windows Guest performs way better than under Centos Guest martdj Linux - Virtualization and Cloud 3 03-29-2010 05:20 AM
KVM Hypervisor and Guest OS setup? Help! sheepy Linux - Server 3 10-15-2009 09:45 PM
XP Guest on Xen switch to KVM marinl Linux - Software 1 06-15-2009 12:25 PM
How to assign public IP to vmware guest OS cucolin@ Linux - Software 12 02-24-2009 06:00 PM
Are KVM guest able to use CPU features ? PlatinumX Linux - Hardware 1 01-03-2009 10:30 AM


All times are GMT -5. The time now is 08:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration