Getting a Virtual Machine’s IP Address from virsh

Ten Years later, and I finally know how to get virsh to tell me the IP address for a VM.

So, I have a virtual machine image called cfme. To launch it, I run

sudo virsh start cfme

That gets me a running virtual machine. To find the domain ID that it has been assigned:

$ sudo virsh list
 Id Name State
----------------------------------------------------
 1 cfme running

And to Find Its IP Address I use the domifaddr subcommand:

$ sudo virsh domifaddr 1
 Name MAC address Protocol Address
-------------------------------------------------------------------------------
 vnet0 52:54:00:e5:5d:e3 ipv4 192.168.122.98/24

From which I can see that the address is 192.168.122.98

Wish I knew this years ago.  Ah well.  Better late then never.

Thanks to and this blog post for showing me the way:

 

 

2 thoughts on “Getting a Virtual Machine’s IP Address from virsh

  1. For even more convenience you can add the libvirt or libvirt-guest NSS module to nsswitch.conf The former does lookups based on the guest’s configured hostname, while the latter does lookups based on the guest name. Both ultimately fetch the IP address from the same source as ‘domifaddr’

    https://wiki.libvirt.org/page/NSS_module

Leave a Reply

Your email address will not be published. Required fields are marked *