Network

Configure VLAN devices over a bond interface

Configuring a VLAN network on Linux is straightforward. Linux supports VLANs through the 8021q driver. This example combines channel bonding and VLAN configuration with the following steps.

  1. Check whether your Linux system supports VLANs by looking for the 8021q driver with this command.
lsmod | grep 8021q
  1. If supported, load the 8021q driver.
modprobe 8021q
  1. Create bond0 at /etc/sysconfig/network-scripts/ifcfg-bond0 and add the following configuration.
DEVICE=bond0
TYPE=Bonding
BOOTPROTO=none
ONBOOT=yes
IPADDR=0.0.0.0
NETMASK=0.0.0.0
USERCTL=no
MII_NOT_SUPPORTED=yes
  1. Edit the eth0 and eth1 configuration files. Set Device=ethN to eth0 for the eth0 file and eth1 for the eth1 file, using the following configuration.
DEVICE=ethN
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
  1. Create a VLAN-capable device. This example configures VLAN 2; the .2 suffix indicates VLAN 2. Create bond0.2 in /etc/sysconfig/network-scripts/, giving the path /etc/sysconfig/network-scripts/bond0.2. Add the following configuration and adjust IPADDR and NETMASK to the required IP and class.
DEVICE=bond0.2
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.1.1
NETMASK=255.255.255.0
USERCTL=no
MII_NOT_SUPPORTED=yes
VLAN=yes
  1. Add the following lines to /etc/modprobe.conf (to load the bond0 driver and configure bond0 in active-standby mode).
install bond0 /sbin/modprobe bonding -o bond0 miimon=100 mode=1
  1. Finally, restart the network service.
service network restart

* The resulting bond0 uses two network interface cards: one active and the other on standby.

EOF.← Back to articles