From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCtb3-00046H-VK for qemu-devel@nongnu.org; Mon, 10 Feb 2014 11:20:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WCtav-0007K0-If for qemu-devel@nongnu.org; Mon, 10 Feb 2014 11:20:37 -0500 Received: from mail-wi0-x22c.google.com ([2a00:1450:400c:c05::22c]:65011) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCtav-0007Jj-CZ for qemu-devel@nongnu.org; Mon, 10 Feb 2014 11:20:29 -0500 Received: by mail-wi0-f172.google.com with SMTP id e4so2993628wiv.11 for ; Mon, 10 Feb 2014 08:20:28 -0800 (PST) Date: Mon, 10 Feb 2014 17:20:25 +0100 From: Stefan Hajnoczi Message-ID: <20140210162025.GB17079@stefanha-thinkpad.redhat.com> References: <354b1ebe.9562.1441963f7ab.Coremail.kvmluck@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <354b1ebe.9562.1441963f7ab.Coremail.kvmluck@163.com> Subject: Re: [Qemu-devel] why mac addresses are different between inside and outside of vm List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: yue-kvm Cc: qemu-devel , virt-maint 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