Skip to content

Instantly share code, notes, and snippets.

@public
Created August 1, 2013 09:14
Show Gist options
  • Save public/6129776 to your computer and use it in GitHub Desktop.
Save public/6129776 to your computer and use it in GitHub Desktop.
Get the IP address of the named running KVM VM. ./virt-ip.sh YOUR-VM
#!/bin/sh
grep $(virsh domiflist $1 | grep -vE '^((.)\2*)?$' | awk 'NR == 1 { for(i=1; i <= NF; i++) { if($i == "MAC") { MAC=i } } } NR > 1 { print $MAC }') /var/lib/libvirt/dnsmasq/default.leases | cut -d\ -f3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment