larsks / blog.oddbit.com

3 stars 0 forks source link

post/2012-12-15-get-vm-ip/ #17

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Getting the IP address of a libvirt domain · The Odd Bit

If you are starting virtual machines via libvirt, and you have attached them to the default network, there is a very simple method you can use to determine the address assigned to your running instance: Libvirt runs dnsmasq for the default network, and saves leases in a local file (/var/lib/libvirt/dnsmasq/default.leases under RHEL). You can get the MAC address assigned to a virtual machine by querying the domain XML description. Putting this together gets us something along the lines of:

https://blog.oddbit.com/post/2012-12-15-get-vm-ip/

sspreitzer commented 2 years ago

This example assumes a bridged network configuration and is not applicable to the NAT use case.

larsks commented 2 years ago

This example is also almost 10 years old and I wouldn't necessarily recommend it as a modern solution.