Last active
August 29, 2015 14:06
-
-
Save langdon/28f7a0a7d486af474ee6 to your computer and use it in GitHub Desktop.
Get IP from virsh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#add this to your bashrc | |
virsh_ip(){ | |
mac=`virsh dumpxml $1 | grep "mac address" | tr -s \' ' ' | awk ' { print $3 } '` | |
for i in `seq 1 10`; do | |
ip=`arp -na | grep $mac | awk '{ print $2 }' | tr -d \( | tr -d \)` | |
if [ "$ip" = "" ]; then | |
sleep 1 | |
else | |
break | |
fi | |
done | |
echo $1 has MAC: $mac and IP: $ip | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment