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'm using KVM with qemu/libvirtd for virtualization in my local network.

Now I'm working on a script which should simplify the cloning and downloading process of virtual machines. For this I need to know the IP addresses of those. For example, get the ip of the fresh created/cloned vm.

The setup is the following:

  • a hypervisor with one bridge which is used by all virtual machines
  • all vms get an ip from an external dhcp server
  • an external dhcp server (on a (which could be replaced by one running on the hypervisor)

Some of the following approaches might be possible:

  • I can get the mac address from the qemu-config files and use it to look up the associated ip address inside the dhcp server
  • Doing a broadcast ping won't return all active vms in the network, but one could use some weird bash loop to ping all 254 ips. (will create some big overhead; I don't like it)
  • After this use arp to grep an ip according to the mac address from the config file

Are there some more elegant ways to achieve this?

share|improve this question
Are you saying you'll have your DHCP server as a VM? If so you might be asking for trouble if the other machines rely on the DHCP server at startup and your VM host is rebooting so the DHCP server isn't available yet... – Bart Silverstrim Nov 15 '11 at 15:33
No, I would put the DHCP server directly on the hypervisor. – dbanck Nov 15 '11 at 21:38

You forgot the most common way - have the VMs run a daemon (or agent, naming doesn't matter) that will report the VM's details to a machine outside. That way you can gather more than just IPs - stats, loads, statuses for critical services etc.

Such an agent already exists for oVirt and the upcoming RHEV builds btw

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.