0

I am using KVM to host a Guest VM. On my host VM, I have created 2 bridges and assigned each to a physical interface (assigned a subnet to them as well).

The routing all works very well, I can ping external resources to and from the interfaces.

I then assigned these 2 bridges to the guest VM, which is running FreeBSD. When I log in to the FreeBSD Guest and view network config, I see these 2 curr medias:

root@VM% ifconfig -a | grep "curr media"
        curr media: i802 52:53:f:6f:e2:b2
        curr media: i802 52:53:f:3b:24:22

When I check out all the interfaces on my Host Ubuntu VM, I see the following:

vnet1     Link encap:Ethernet  HWaddr fe:53:0f:6f:e2:b2
vnet2     Link encap:Ethernet  HWaddr fe:53:0f:3b:24:22

This is extremely confusing, as I would assume the interface in FreeBSD would have the same mac address as the associated VNET.

Does FreeBSD change the mac addresses from fe to 52? Or does the freeBSD interface take on a different mac address than the associated VNET?

More related confusions:
1) If 2 bridges, with routing, are assigned to a guest VM, is there a VNET created for each bridge on the host?
2) If 2 bridges are created, one assigned to 1 VM, and another assigned to another VM. Would there still be 2 VNETS?
3) If 2 bridges, are created on a host VM. However, one bridge is assigned to 1 VM and another bridge is assigned to 2 VMs, would there be 3 VNETS created on the host VM?

The reason for this clarification is because I see a whole bunch of VNETs.. and I have not idea where they come from (as I cannot seem to make sense of the MAC addresses) and I cannot seem to take them off because they arent in the network/interfaces file of ubuntu.

2

When using KVM, the interface MAC address on the host side is never the same as the MAC address inside the VM, regardless of the OS. It's a consequence of TUN/TAP networking.

For example, with a CentOS 7 VM running:

$ ip link show v-test1
64: v-test1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 500
    link/ether fe:54:00:0c:d8:88 brd ff:ff:ff:ff:ff:ff

$ ssh test1 /sbin/ip link show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 52:54:00:0c:d8:88 brd ff:ff:ff:ff:ff:ff

We can see similar with a Solaris 11 VM:

55: v-solaris: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 500
    link/ether fe:54:00:94:47:6d brd ff:ff:ff:ff:ff:ff

$ ssh solaris ifconfig -a
....
net0: flags=100001004843<UP,BROADCAST,RUNNING,MULTICAST,DHCP,IPv4,PHYSRUNNING> mtu 1500 index 2
        inet 10.0.0.157 netmask ffffff00 broadcast 10.0.0.255
        ether 52:54:0:94:47:6d 

So it doesn't matter what the VM OS is; the MAC address seen inside the VM will always be different to that seen on the host side.

Now you can normally pick the interface name on the host side and the MAC address on the guest side via the configuration. I use libvirt to manage my VMs and so in my guest.xml file I have

<interface type='bridge'>
  <mac address='52:54:00:0c:d8:88'/>
  <source bridge='br0'/>
  <target dev='v-test1'/>
  <model type='virtio'/>
</interface>

This creates a network called "v-test1" on the host and the MAC address inside the guest is specified. This matches the first example above.

If you specify two network adapters for a host then you can pick what bridge on the host they are on, the network interface name as seen on the host, and the MAC addresses indepedently.

eg

<interface type='bridge'>
  <mac address='52:54:00:0c:44:5d'/>
  <source bridge='br0'/>
  <target dev='v-test2'/>
  <model type='virtio'/>
</interface>
<interface type='bridge'>
  <mac address='52:54:00:0c:44:5e'/>
  <source bridge='internal'/>
  <target dev='v-test2b'/>
  <model type='virtio'/>
</interface>

So now I've defined two interfaces, called one v-test2 and put it on bridge "br0" and another called v-test2b and put it on bridge "internal"

$ ip addr show v-test2
68: v-test2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 500
    link/ether fe:54:00:0c:44:5d brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fc54:ff:fe0c:445d/64 scope link 
       valid_lft forever preferred_lft forever

$ ip addr show v-test2b
69: v-test2b: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 500
    link/ether fe:54:00:0c:44:5e brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fc54:ff:fe0c:445e/64 scope link 
       valid_lft forever preferred_lft forever

$ brctl show
bridge name     bridge id               STP enabled     interfaces
br0             8000.0025222613c0       no              eth0
....
                                                        v-test2

internal                8000.fe54000c445e       no              v-test2b

And inside the guest we see them:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 52:54:00:0c:44:5d brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 52:54:00:0c:44:5e brd ff:ff:ff:ff:ff:ff

This makes it possible to define exactly what interfaces and MAC addresses and bridges each VM has.

  • Apologies, I edited the question. Is there a way of associating which interface in the guest VM is associated with which interface on the host? Because If I was to assign IP addresses to a whole bunch of interfaces on a guest.. I wouldn't know what the associated bridge (and hence the associated physical interface) is – user2883071 Aug 18 '16 at 13:37
  • Does the updated answer help? – Stephen Harris Aug 18 '16 at 13:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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