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

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use XEN virtualization platform. I have configured its networking in xenbr0 mode. I have set up one base VM and I am cloning it to create new VMs by using virt-clone command.

My question is there any way I can provide the IP address for the new VM at the time of creating itself. Like can I pass IP address for this VM as a parameter to some command so it will set its IP address.

I searched help of virt-clone command but didn't find anything useful. You can pass mac address as parameter but not IP address. So is there any other way.

Also I want this IP address to be permanent one so that if I reboot the VM, it will not lose its IP.

We want static IPs in our network so DHCP is not an option.

share|improve this question
quick question why no DHCP? – tony roth Sep 21 '11 at 15:09
Because in our lab environment we do not want DHCP server. And if you are referring to set up DHCP on DOM0 only for VMs, I am suspecting that idea because we use IP provided to these VMs in other applications to manage them. So if DHCP is used each boot can provide VMs different IPs, which will differ from the initial IPs that we have used to add them in management application. Basically it can create inconsistencies, that's why! – stillStudent Sep 21 '11 at 15:20
You can assign static IP's via DHCP. You just bind a particular IP to a particular MAC address. If you can specify a MAC when cloning, you could have your DHCP server already configured for a set of IP/MAC combinations. Clone with the MAC you specified in the DHCP setting and you're good. – Jason Taylor Sep 21 '11 at 15:27
under dhcp if the mac doesn't change the ip does not change unless something overides this condition. – tony roth Sep 21 '11 at 15:57
Thank you, I will try to set up DHCP with IP MAC mapping and see what happens. – stillStudent Sep 22 '11 at 7:55
up vote 0 down vote accepted

I think the answer to this has to be "no". Given that a VM could be any OS type - so configuring an IP in Windows is different to Linux. But even if they were all linux VMs, different distributions store IP configuration in different places. There is no way for virt-clone to track any of this, and it isn't its role. As commenters have said, dhcp is the right way to do this - you can control MAC addresses outside of the VM so you have fine control over what IP each server gets.

If dhcp is really out of the question, though it doesn't seem to be, I would configure your source VM that you are cloning with a static IP that isn't used elsewhere. Then have a startup script on this VM that talks to some central store to obtain its post-cloning IP and hostname configuration at startup. So it boots with the standard IP address, retrieves its "proper" configuration from somewhere, and reconfigurs its IP address during its first boot.

Of course, in doing all this you are effectively replicating dhcp in a half assed way :)

Another option would be to virt-clone the VM, then run a script that mounts the partition containing /etc/ and updates the IP address configuration.

share|improve this answer
Second option also seems good, I was trying it but was mounting image file, which failed. Any way thank you for your help. – stillStudent Sep 22 '11 at 7:57

I'm not sure you will see this, I know a way to complete your request, first create a system service in the VM, the service listens for commands sent xenserver (like Xs-Tools), but this service is used to change IP. but the problem is how to make xenserver send this change IP command to the VM.

share|improve this answer

I think the answer is no. The same was asked in the Citrix forums before and the reason is actually very simple. Xen is the virtualization layer, so it can create the VM but inside configuration which is done in the OS is actually not related to Xen anymore. Configuring an IP is basically editing the network configuration inside the operating system. Something outside Xen scope.

This could be done by first creating the VM and then once its running change the network settings. But not on the VM creation. Im not sure if Xen has a command but even if it doesn't you could use any provision tool directly on the OS.

You could always change the network settings with some script once its running and restart the network, that would accomplish the same thing.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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