Skip to content

Instantly share code, notes, and snippets.

@aastaneh
Created May 3, 2018 11:27
Show Gist options
  • Save aastaneh/43e327be9da6b930e8063b7529155254 to your computer and use it in GitHub Desktop.
Save aastaneh/43e327be9da6b930e8063b7529155254 to your computer and use it in GitHub Desktop.
a terrible bash script that uses the ARP table to determine IP addresses for running KVM guests on a bridged interface
#!/bin/bash
for vm in $(virsh list --state-running --name); do
echo -n "$vm "
arp | grep $(virsh domiflist $vm | sed '/^$/d' | tail -n1 | awk '{ print $NF}') | awk '{ print $1 }'
done
# $ script.sh
# vm1 192.168.1.100
# vm2 192.168.1.101
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment