Linux Ethernet Bonding – load balancing / active-passive

This is a notice in the topic of Linux Ethernet Bonding with two ethernet NIC

The case:
There is a server with two ethernet NIC. They are going to be set as either load balancing or active-passive mode.

  1. For load balancing (round-robin) – mode = 0, this is the default, transmitting packets in order from the first available slave through the last, for load balancing and fault tolerance.
  2. For active-passive – mode = 1, Only one of the bond slaves is used, and the others act as stand-by mode. Once the active one failure, after particular time period (miimon=xxx), the stand-by one will take over and resume the network connection.

For Load balancing mode

Add line to /etc/modprobe.conf

alias bond0 bonding # Kernel nic bonding driver
options bond0 mode=0 # Mode 0 = load balancing

For active-passive mode

Add line to /etc/modprobe.conf

alias bond0 bonding # Kernel nic bonding driver
options bond0 mode=1 miimon=100 max_bonds=2 # Mode 1 = active-passive

Create / edit file ifcfg-eth0 and ifcfg-eth1 under /etc/sysconfig/network-scripts/ as following

DEVICE=eth0 #edit as eth1 for file ifcfg-eth1
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
MII_NOT_SUPPORTED=yes

Create /etc/sysconfig/network-scripts/ifcfg-bond0 as following

DEVICE=bond0
IPADDR=1.2.3.4 # change as your IP
NETMASK=255.xxx.xxx.xxx # change as your netmask
GATEWAY=1.1.1.254 # change as your gateway
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
MII_NOT_SUPPORTED=yes

Restart the network service

/etc/init.d/network stop;
/etc/init.d/network start;

Reference:
Bonding Ethernet Interfaces in Linux

Linux Ethernet Bonding Driver HOWTO

Leave a Reply

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Close Menu