Skip to content

Instantly share code, notes, and snippets.

@larsks larsks/virt-addr
Created Dec 15, 2012

Embed
What would you like to do?
Get the address of a libvirt virtual instance
#!/bin/sh
mac=$(virsh dumpxml $1 |
xml2 |
awk -F= '$1 == "/domain/devices/interface/mac/@address" {print $2; exit}')
ip=$(awk -vmac=$mac '$2 == mac {print $3}' /var/lib/libvirt/dnsmasq/default.leases )
echo $ip
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.