WARNING!

this only works if vms have dhcp assigned addresses of the network “default”!

# iterate over all vms by name
for i in $(virsh list | grep running | awk '{print $2}'); do virsh domifaddr $i; done
Name MAC address Protocol Address
-------------------------------------------------------------------------------
vnet2 52:54:00:54:XX:XX ipv4 192.168.122.148/24
# for easier re-use script it
vim /scripts/kvm/list_all_ips.sh
# alternatively the manual way
virsh domifaddr debian12
Name MAC address Protocol Address
-------------------------------------------------------------------------------
vnet2 52:54:00:54:7c:e7 ipv4 192.168.122.148/24

# alternatively (only lists all dhcp assigned ips)
# list all virtual networks
virsh net-list


# setup the default dhcp network (the dhcp will not be public only on the local machine)
virsh net-start default
virsh net-autostart default

virsh net-dhcp-leases default

 Expiry Time           MAC address         Protocol   IP address           Hostname    Client ID or DUID
-------------------------------------------------------------------------------------------------------------------------------------------------
 2024-01-08 13:08:39   52:54:00:15:XX:XX   ipv4       192.168.122.207/24   ubuntu      ff:56:50:4d:...
 2024-01-08 13:42:21   52:54:00:95:XX:XX   ipv4       192.168.122.162/24   debian12    ff:00:95:9d:6e:...
 2024-01-08 13:40:09   52:54:00:aa:XX:XX   ipv4       192.168.122.249/24   vmname   -

alternatives:

su - root
apt install netdiscover
# arp scans local network
netdiscover

command might be useful (does active/passive ARP scanning)

netdiscover.man.txt

if this all did not help: checkout the hacks and scripts

links:

GNU Linux How To – kvm qemu shutdown all vms – start all vms with keyword in name – snapshot all vms

liked this article?

  • only together we can create a truly free world
  • plz support dwaves to keep it up & running!
  • (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
  • really really hate advertisement
  • contribute: whenever a solution was found, blog about it for others to find!
  • talk about, recommend & link to this blog and articles
  • thanks to all who contribute!
admin