From: Stefan Hajnoczi <stefanha@gmail.com>
To: yue-kvm <kvmluck@163.com>
Cc: qemu-devel <qemu-devel@nongnu.org>,
virt-maint <virt-maint@lists.fedoraproject.org>
Subject: Re: [Qemu-devel] why mac addresses are different between inside and outside of vm
Date: Mon, 10 Feb 2014 17:20:25 +0100 [thread overview]
Message-ID: <20140210162025.GB17079@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <354b1ebe.9562.1441963f7ab.Coremail.kvmluck@163.com>
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
prev parent reply other threads:[~2014-02-10 16:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-10 1:23 [Qemu-devel] why mac addresses are different between inside and outside of vm yue-kvm
2014-02-10 16:20 ` Stefan Hajnoczi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140210162025.GB17079@stefanha-thinkpad.redhat.com \
--to=stefanha@gmail.com \
--cc=kvmluck@163.com \
--cc=qemu-devel@nongnu.org \
--cc=virt-maint@lists.fedoraproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).