virsh - list all mac addresses for all network interfaces of any type
Matthew Barrera
I'm trying to identify one of a few dozen virtual machines by a given mac address (52:54:00:: OUI, mapping to QEMU),
the following lists the dhcp table from the NAT based virtual machine adapters, however many of these virtual machines have host device macvtap adapters.
virsh net-dhcp-leases defaultthe macvtap adapters mac addresses are shown in virt-manager for each network interface, whats the virsh command to query all network adapter's mac addresses?
2 Answers
You can use virsh to do this
# virsh domiflist vmnameFor all the VMs use;
# for i in `virsh list --all --name`; do echo $i; virsh domiflist $i; done 1 I didn't see an obvious way to do this in virsh natively, but I enumerated it with the following shell command:
virsh list --all --name \ | while read line; do ( \ virsh domiflist $line \ | sed 's,^,'$line': ,' \ ); done \
| grep 52:54:00:<my_mac_suffix>