Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using qemu/kvm whith bridged networking. In the host machine there are several "vnetX" network interfaces without IP. I'm looking for a way to know which vnetX belong to a virtual machine.

I tried to match the MAC Address values on these interfaces with the MACs on the virtual machines (or the XML which defines them), but doesn't match.

There's brctl show which shows the vnet interfaces that belongs to a bridge, but this is not useful info.

Is there a way to know that relation? Thx!!

share|improve this question
up vote 11 down vote accepted

How about this (example for vnet13):

$ VNET=vnet13; for vm in $(virsh list | grep running | awk '{print $2}'); do virsh dumpxml $vm|grep -q "$VNET" && echo $vm; done

Here we use virsh dumpxml to show dynamic properties about the VM, which are not available in the static XML definition of the VM in /etc/libvirt/qemu/foo.xml. Which vnetX interface is attached to which VM is such a dynamic property. Same goes for the VM's MAC addresses.

share|improve this answer
Thanks a lot :) – anishsane Nov 20 '12 at 10:00
I use this slight modification to list which vm has which interface: for vm in $(virsh list | grep running | awk '{print $2}'); do echo -n "$vm:"; virsh dumpxml $vm| grep -oP "vnet\d+" ; done – zje Oct 20 '14 at 23:10
If you are investigating an oVirt 'node' you can use the same command but virsh should be run in 'read only' mode. Just add -r parameter to each virsh call. – karlacio Jan 11 at 21:56

Try virsh dumpxml $domain, you'll see something like:

  <interface type='network'>
  <mac address='52:54:00:9d:9d:10'/>
  <source network='default'/>
  <target dev='vnet1'/>
  <model type='e1000'/>
  <alias name='net1'/>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x0c' function='0x0'/>

the alias name is what is used in the qemu-kvm command line, so if you run ps -ef |grep qemu|grep net1 from my example, you will see the actual command syntax used for this interface.

share|improve this answer

The MAC address of the vnetX interfaces belongs to the host, not the guest. brctl showmacs br0 will show the MACs detected by the bridge, but you'd then need to cross reference the port number with the list of interfaces from brctl show.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.