Forward Bond interface VLAN to guest KVM

Hello, here is part two of forwarding VLANs to KVM guest.
First part was t forward VLANs via trunk interface using bridges:
https://henroo.wordpress.com/2011/03/25/how-to-add-vlan-network-to-kvm-guest/

Now I will show you how to bond two interfaces using Dynamic Link Agregation and to make it all work with VLANs and bridges. It will give us better network performance and fault tolerant connection.

So let’s start 🙂 Here is drawing that shows how it all should work. I’m connecting serwer with SPS2024 Linksys switch:

First we have to customize kernel modules. To make it we have to create a file /etc/modprobe.d/bond0.conf

alias bond0 bonding
options bond0 mode=4 miimon=100

I’m using mode 4 which is IEEE 802.3ad Dynamic link aggregation. It works well with my switch so I didn’t try other modes. If you want to try the here is description:
http://wiki.centos.org/TipsAndTricks/BondingInterfaces

Ok so now we have to configure our eth1 and eth2 interfaces to work together as one bond0 interface.
Create ifcfg-eth1 and ifcfg-eth2 ifcfg-bond0 files:
/etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE="eth1"
ONBOOT="yes"
BOOTPROTO=none
SLAVE=yes
MASTER=bond0
USERCTL=no

/etc/sysconfig/network-scripts/ifcfg-eth2
DEVICE=”eth2″
ONBOOT=”yes”
BOOTPROTO=none
SLAVE=yes
MASTER=bond0
USERCTL=no

/etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
BOOTPROTO=none
ONBOOT=yes

Now we have two interafes bond as one, so we can add VLAN tagging to bond0. You have to make sure that 802.1Q modeule is loaded. This is most easily done with modprobe. So the command:

sbin/modprobe 8021q

To forward VLAN to KVM guests we have to create interfaces that are using untagged frames from specific VLANs and add them to bridge interfaces.
We will create interface from VLAN 4 and forward it to bridge4. It can be done by creating files:

/etc/sysconfig/network-scripts/ifcfg-bond0.4
DEVICE=bond0.4
VLAN=yes
ONBOOT=yes
BRIDGE=br4

/etc/sysconfig/network-scripts/ifcfg-br4
DEVICE=br4
TYPE=Bridge
BOOTPROTO=none
ONBOOT=yes

And to finish everything restart the network service and now using virt-manager you can connect your guest to VLAN4 by adding br4 network interface.

Advertisements

7 thoughts on “Forward Bond interface VLAN to guest KVM

  1. TooMeeK says:

    VERY interesting, will try this later!

  2. vk says:

    confused with network. please help, eth0 is static/management interface for kvmhost and eth1 is enabled with 802.1q on the interface, vlan and bridge is configured. missing configuration, not able to get the routing properly.

    • henroo says:

      Hi
      so eth1 and eth2 are physical interfaces from the kvm host machine. Both of them are working as link agregate. You make one logical interface called bon0 which consists of eth1 and eth2.
      Next step is to make kvm host aware of vlans connected to eth1 and eth2 so you have to create configuration for VLAN X in a configuration file bond0.X
      final step is to connect bond0.X interface with some bridge brX so that you could forward it to kvm guest. You can do this by inserting a line in bond0.X config

      BRIDGE=brX

      • vk says:

        thanks for your reply, but how did you make your routing between eth0 and bond0. i have bladeG7 in c7000. vlan is configured in virtual connect. eth0 and eth1 are configured with different vlans. eth0 is configured wtih static ip and eth1 is configured with bridge with out ip. but not able to get ipaddr. some where i am missing routing. do you have any idea

  3. vk says:

    getting errror no filername or root path specified

  4. Ceryx says:

    THANK YOU. I struggled with this for hours before coming across this and realizing that I needed to create and attach bond0.#### interfaces for all vlans to the bridge, not just bond0 itself. Was assuming KVM would tag traffic on its own.

  5. RIchard says:

    “And to finish everything restart the network service and now using virt-manager you can connect your guest to VLAN4 by adding br4 network interface.”
    Could someone explain how to do this without using virt-manager?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s