Saturday, June 7, 2014

libvirt virsh How to find IP address of Guest VM

1)
Goto the Host machine
 
2)
List all VMS and find ID of the VM

# virsh list --all
 Id    Name          State
--------------------------------------------
 31    my-vm1     running

3)
Find MAC Address of the VM 31 (my-vm1)

# virsh domiflist 31
Interface  Type       Source     Model       MAC
-------------------------------------------------------
vnet0      network    default    virtio      59:51:50:b4:72:65

4)
Find IP of the VM 31 (my-vm1) from ARP table

# arp -e
Address                  HWtype  HWaddress           Flags Mask            Iface
192.168.161.22           ether   59:51:50:b4:72:65  C                     virbr0
10.145.136.1             ether   09:03:5c:07:12:04   C                     eth2

5)
OR, You can just read the lease file and Find IP of the VM 31 (my-vm1)

# cat /var/lib/libvirt/dnsmasq/default.leases
1132046030 59:51:50:b4:72:65 192.168.161.22 opshost *

6)
IP of the VM VM 31 (my-vm1) is : 192.168.161.22




1 comment:

  1. http://stackoverflow.com/questions/19057915/libvirt-fetch-ipv4-address-from-guest

    ReplyDelete