Categories

Archives

Configuring bridging, bonding, vlans on CentOS/RedHat 6.x

Redhat / CentOS — Bridging, Bonding, Vlan’s

/etc/sysconfig/network-scripts/ifcfg-em1 and em2

DEVICE=<device-name>
ONBOOT=yes
HWADDR=MAC:MAC:MAC:MAC:MAC:MAC

/etc/sysconfig/network-scripts/ifcfg-em1.vlanid (example ifcfg-em1.20)

DEVICE=<device>.<vlanid>
ONBOOT=yes
VLAN=yes
BOOTPROTO=none
SLAVE=yes
MASTER=bond

/etc/sysconfig/network-scripts/ifcfg-bond (example ifcfg-bond20)

DEVICE=bond<vlanid>
ONBOOT=yes
BONDING_OPTS="mode=active-backup primary=em1 miimon=100"
BOOTPROTO=none
BRIDGE=br<vlanid>
MACADDR=<RANDOM_MAC>

/etc/sysconfig/network-scripts/ifcfg-br (example ifcfg.br20)

DEVICE=br<vlanid>
ONBOOT=yes
TYPE=Bridge
DELAY=0
BOOTPROTO=static
IPADDR=X.X.X.X
NETMASK=X.X.X.X

So, creating 3 vlans (20, 200, 250) on a 2 interface bond (em1, em2) creates the following set of configfiles:

ifcfg-em1
Base configuration for em1
ifcfg-em2
Base configuration for em2
ifcfg-em1.20
Vlan 20 interface on em1 interface
ifcfg-em1.200
Vlan 200 interface on em1 interface
ifcfg-em1.250
Vlan 250 interface on em1 interface
ifcfg-em2.20
Vlan 20 interface on em2 interface
ifcfg-em2.200
Vlan 200 interface on em2 interface
ifcfg-em2.250
Vlan 250 interface on em2 interface
ifcfg-bond20
Bonding em1.20 with em2.20
ifcfg-bond200
Bonding em1.200 with em2.200
ifcfg-bond250
Bonding em1.250 with em2.250
ifcfg-br20
Create a bridge on bond20
ifcfg-br200
Create a bridge on bond200
ifcfg-br250
Create a bridge on bond250

4 comments to Configuring bridging, bonding, vlans on CentOS/RedHat 6.x

  • Hazzardd

    Has anyone ran into a limitation with how many VLANs you can assign to a single interface? Below is my configuration, and I can only ping the first 2 VLANs of each interface. VLAN 2.11, 2.12, 3.16, and 3.17….. All others are not ping-able. I am running CentOS Linux 6.5

    eth2 Ethernet No address configured None
    Yes
    eth2.11 Ethernet VLAN 192.168.10.6 255.255.255.252
    Yes
    eth2.12 Ethernet VLAN 192.168.10.10 255.255.255.252
    Yes
    eth2.13 Ethernet VLAN 192.168.10.14 255.255.255.252
    Yes
    eth2.14 Ethernet VLAN 192.168.10.18 255.255.255.252
    Yes
    eth2.15 Ethernet VLAN 192.168.10.22 255.255.255.252
    Yes
    eth3 Ethernet No address configured None
    Yes
    eth3.16 Ethernet VLAN 192.168.10.26 255.255.255.252
    Yes
    eth3.17 Ethernet VLAN 192.168.10.30 255.255.255.252
    Yes
    eth3.18 Ethernet VLAN 192.168.10.34 255.255.255.252
    Yes
    eth3.19 Ethernet VLAN 192.168.10.38 255.255.255.252
    Yes
    eth3.20 Ethernet VLAN 192.168.10.42 255.255.255.252
    Yes
    lo Loopback 127.0.0.1 255.0.0.0
    Yes

    Thanks,
    Kevin

    • sig-io

      I have systems with >100 vlan’s on a single interface without any problems. Maybe your switch doesn’t like them?

  • Tilman Schmidt

    You advocate creating VLAN subinterfaces on the physical interfaces and bond interfaces on top of those, ie. splitting out the VLANs first and then bonding the individual VLANs.
    I’ve seen other sources suggest doing it the other way around, creating a bonding interface on the physical interfaces and VLAN subinterfaces on that, ie. bonding the entire trunk and then splitting out the VLANs.
    Can you comment on the advantages and disadvantages of one or the other approach?
    Thanks,
    Tilman

    • sig-io

      Either way would probably work… this is what I used, wouldn’t know any advantages of the one method over the other.