[libvirt-users] list mac or IP of all guests NICs?

Justin Clift jclift at redhat.com
Tue Jan 18 05:57:53 UTC 2011


On 18/01/2011, at 7:45 AM, Josiah Ritchie wrote:
> I'm trying to figure out how to use virsh (or something else) to list all the IP addresses (or MAC addresses if needed) for each virtual NIC, preferably with it domain affiliation also listed.
> 
> Is this possible?

Hi Josiah,

It should be pretty straight forward to get the MAC addresses of things.

The (scripting) approach that's coming to mind, is to first use virsh to get a list of all the domains (using "virsh list --all") or similiar.

Then, for each of the domains, run the virsh "dumpxml" command, which includes the MAC address on one of the network device lines.

Getting the IP addresses associated with each MAC isn't always quite as easy.  It depends on how IP addresses are given to the guests.  For example they could be given out via a DHCP server controlled by libvirt.  Or they could be given out via a DHCP on a real physical network.  (both quite possible)  Alternatively, they could be hard coded statically inside each guest (so libvirt doesn't know what it is), or any combination of the above

I'm pretty sure there are scripts around, that will help automate the collection of IP addresses for some of these.  From memory Richard Jones (on this mailing list already) has a blog entry or two on this subject.  He'll probably post a link if my memory isn't being dodgy. :)

Does any of that help?

Regards and best wishes,

Justin Clift




More information about the libvirt-users mailing list