如何查看libvirt虚拟机的ip地址
转自:http://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/view-dynamic-ip-address-allocation-with-virsh-4175482470/
#!/bin/bash -x MAC=$(awk '/virbr0/ { print $4 }' /proc/net/arp ) for VM in $(virsh list | awk '!/Name/ {print $2}') do if virsh dumpxml $VM | grep $MAC &> /dev/null then awk '/virbr0/ { gsub(/'$MAC'/,"'$VM'"); print $1,$4}' /proc/net/arp fi done
思想:通过virsh dumpxml查看虚拟机的mac地址,之后到 /proc/net/arp文件中通过mac地址查询对应的ip地址。