Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
libvirt get ip address
# Method 1:
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)
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