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 fritz.box) (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?