[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] why mac addresses are different between inside and outs
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] why mac addresses are different between inside and outside of vm |
Date: |
Mon, 10 Feb 2014 17:20:25 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Mon, Feb 10, 2014 at 09:23:05AM +0800, yue-kvm wrote:
> nwfilter has many rules which depends on the mac of vm, but i find the mac
> address inside vm is different from mac outside of vm.
> outside mac:
> vnet0 Link encap:Ethernet HWaddr FE:54:00:71:15:7B ,
> inside mac:
> eth0 Link encap:Ethernet HWaddr 52:54:00:71:15:7B ,virtio
> it looks like vnet* are always changed to start with FE, why?
> where is the code to do this?
The reason for different addresses is that the host-side tap interface
is different from the guest-side NIC. They use different MAC addresses
so that ARP and everything else works correctly. See libvirt
src/util/virnetdevtap.c:virNetDevTapCreateInBridgePort().
Why 0xfe? Because the Linux bridge interface takes on the MAC address
of the (numerically) lowest MAC. Therefore, starting with 0xfe will
make sure the bridge gets the MAC of the physical interface (i.e. host
eth0). See Linux net/bridge/br_stp_if.c:br_stp_recalculate_bridge_id().
Stefan