I have several VMs running on Ubuntu 9.10 via KVM+libvirt. I want to be able to find out the IP address that has been assigned to each host without physically opening a physical "console" to each machine and invoking ifconfig
.
Consider:
rascher@localhost:~$ virsh -c qemu:///system list --all Connecting to uri: qemu:///system Id Name State ---------------------------------- 1 machine1 running 2 machine2 running - machine3 shut off
My network configuration looks like:
<network>
<name>default</name>
<uuid>1be...</uuid>
<forward mode='route' dev="eth0"/>
<bridge name='virbr0' stp='on' forwardDelay='0' />
<ip address='192.168.122.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.168.122.2' end='192.168.122.254' />
</dhcp>
</ip>
</network>
So how can I get a listing which says:
machine1 IP address = 192.168.122.16 machine2 IP address = 192.168.122.238 ...
I played with arp
:
rascher@localhost:~$ arp Address HWtype HWaddress Flags Mask Iface 192.168.122.238 ether 00:16:36:00:61:b0 C virbr0 192.168.122.16 ether 00:16:36:52:e8:9c C virbr0 ...
But this doesn't map to a virtual machine's ID.
Is there some tool (via the command line, virsh
or virt-*
) I can ascertain this information? Or do I need to have some fancy script which runs on each individual VM, checks its own IP, and reports it back to the host OS?
Best Answer
This feature was requested a long time ago. Now libvirt supports it by providing two new commands: domifaddr and net-dhcp-leases
In a different scenario: