Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
libvirt get ip address
# Method 1:
#
# https://rwmj.wordpress.com/2010/10/26/tip-find-the-ip-address-of-a-virtual-machine/
arp -an | grep $(virsh dumpxml $VIRTUAL_MACHINE_NAME | grep '<mac' | grep -o '\([0-9a-f][0-9a-f]:\)\+[0-9a-f][0-9a-f]') | grep -o '\([0-9]\{1,3\}\.\)\+[0-9]\{1,3\}'
# Method 2: (needs guest-agent)
#
# http://dustymabe.com/2013/07/14/find-guest-ip-address-using-qemu-guest-agent/
virsh qemu-agent-command $VIRTUAL_MACHINE_NAME '{"execute":"guest-network-get-interfaces"}' | python -mjson.tool
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.