Skip to content

Instantly share code, notes, and snippets.

@langdon
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save langdon/28f7a0a7d486af474ee6 to your computer and use it in GitHub Desktop.
Save langdon/28f7a0a7d486af474ee6 to your computer and use it in GitHub Desktop.
Get IP from virsh
#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