How to find the IP address of a KVM Virtual Machine, that I can SSH into it?

Try this:

virsh net-list
virsh net-dhcp-leases <net-name>   <--- net-name from above command

You can also use following form if you know the MAC address:

virsh net-dhcp-leases <net-name> --mac <mac-address>

The MAC address can be found from dumpxml command.  See Is there a way to determine which virtual interface belongs to a virtual machine in a kvm host?


You can run arp -n to see what IP your virtual machine pick up. In that way, you don't have to login guest vm and type ifconfig.

The blog below has more details and includes a perl script which automates finding the address of a virtual machine.

Tip: Find the IP address of a virtual machine


I guess this is an old question, but the current versions of virsh make this a lot easier if you're using a nat or bridged private network. I have a virtual machine named steak on a (routed) private network (AKA "NAT"). It's just two commands to find what IP is was assigned by the built-in mechanism:

$ sudo virsh list
 Id    Name                           State
----------------------------------------------------
 21    steak                          running

$ sudo virsh domifaddr steak
 Name       MAC address          Protocol     Address
-------------------------------------------------------------------------------
 vnet0      76:0c:28:ab:0e:ee    ipv4         10.14.1.1/24

I also have another VM (eggs) which is bridged to the regular network (connected to a bridge device on the hypervisor host). Libvirt doesn't assign it an address; it gets an address from my network's DHCP server, which also updates dynamic DNS in my case. That's one likely possibility when there's no output from domifadd for this VM. So, you basically have to find the address like it's any other machine - finding it in the arp table is probably the easiest -- which means ip neighbour now, as arp is deprecated and no longer present on some distributions. Luckily for those of us who don't spell things with extrae vouwels, you can also use shorter versions, like ip neigh and ip n (or ip neighbor). ;) Below, I use domiflist to find the MAC address (note that it's connected to br0 in the "source" column) and then find that in the arp table.

$ sudo virsh domifaddr eggs
 Name       MAC address          Protocol     Address
-------------------------------------------------------------------------------

$ sudo virsh domiflist eggs
Interface  Type       Source     Model       MAC
-------------------------------------------------------
vnet0      bridge     br0        virtio      52:54:00:2c:ac:ee

$ ip neigh | grep -i 52:54:00:2c:ac:ee
192.168.0.226 dev br0 lladdr 52:54:00:2c:ac:ee REACHABLE
$ host eggs
eggs.home.domain.com has address 192.168.0.226