There’s a time you want to check virtual guest’s IP, but no way to access the machine as you only have text terminal.
You can retrieve IP address by using the following script.
#!/bin/bash macaddress=`virsh dumpxml $1 | grep "mac address" | awk 'BEGIN { FS = "=" }; {print $2}' | sed 's//>/ /'` macaddress=`echo $macaddress | sed "s/'/ /g"` ipaddr=`grep $macaddress /var/lib/libvirt/dnsmasq/default.leases | awk '{print $3}'` echo VM $1 uses $ipaddr "($macaddress)"
It’s quite simple, but would be useful if you want to check it quickly.
http://pagead2.googlesyndication.com/pagead/show_ads.js
# ./extrace_vm_ip.sh Fedora-node1 VM Fedora-node1 uses 192.168.122.53 ( 52:54:00:13:3e:90 )
Leave a Reply