Wednesday, April 29, 2015

how do i find the ip address of a vm running on a kvm server

 How do I find out the IP address of a VM on a KVM server?  
   
 Fill the ARP table and using virsh figure it out!   
   
 Run:  
   
 for i in {1..249}  
  do  
  ping -c 1 -n -q -r -t 1 -s 1 -W 1  10.6.66.$i > /dev/null &  
 done  
   
 Then:  
   
 for name in `virsh list | grep running | awk '{ print $2 }'`  
 do  
  printf "\n$name\n "  
  arp -e | grep "`virsh dumpxml $name | grep "mac address"|sed "s/.*'\(.*\)'.*/\1/g"`" |  
  awk '{ printf $1 ; printf " " ; printf $3 }'  
 done  
   

No comments: