Linux allows binding of multiple network interfaces into a single channel/NIC using special kernel module called bonding. According to official bonding documentation:

    The Linux bonding driver provides a method for aggregating multiple network interfaces into a single logical “bonded” interface. The behavior of the bonded interfaces depends upon the mode; generally speaking, modes provide either hot standby or load balancing services. Additionally, link integrity monitoring may be performed.

In the example below, I'm using a Linux server that has 4 network interfaces, SL6, kernel and bonding module info is here:

# modinfo bonding
filename:       /lib/modules/2.6.32-504.12.2.el6.x86_64/kernel/drivers/net/bonding/bonding.ko
author:         Thomas Davis, This email address is being protected from spambots. You need JavaScript enabled to view it. and many others
description:    Ethernet Channel Bonding Driver, v3.6.0
version:        3.6.0
license:        GPL
srcversion:     332968C1FF133A42ED33D6B
depends:        8021q,ipv6
vermagic:       2.6.32-504.12.2.el6.x86_64 SMP mod_unload modversions

Eethernet interfaces

# ifconfig | grep eth 
eth0      Link encap:Ethernet  HWaddr 00:1F:4F:A6:F9:51
eth1      Link encap:Ethernet  HWaddr 00:1F:4F:A6:F9:52
eth2      Link encap:Ethernet  HWaddr 00:1F:4F:A6:F9:53  
eth3      Link encap:Ethernet  HWaddr 00:1F:4F:A6:F9:54  

 

Here is the bonding steps:

 #1: Create a Bond0 Configuration File

RHEL/CentOS/SL store network configuration in /etc/sysconfig/network-scripts/ directory. So first, you need to create a bond0 config file as follows:

# vi /etc/sysconfig/network-scripts/ifcfg-bond0

Append the following linest:

DEVICE=bond0
IPADDR=192.168.1.1
NETWORK=192.168.1.0
NETMASK=255.255.255.0
USERCTL=no
BOOTPROTO=none
ONBOOT=yes

Surely you need to replace IP address with your actual setup.


#2: Modify eth0/2/3/4 config files

Modify all of configuration files, and modify/append directive as follows:

# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none


Repeat same changes for eth1, eth2, eth3

# 3: Load bond driver/module

Next is to load bonding driver into kernel. This has to be done before the channel-bonding interface (bond0) is brought up.

Modify kernel modules configuration file, append following two lines to  /etc/modprobe.conf

alias bond0 bonding
options bond0 mode=balance-alb miimon=100

# 4: Test configuration

First, load the bonding module, enter:

# modprobe bonding

Restart the networking service in order to bring up bond0 interface, enter:

# service network restart

Run cat command to query the current status of Linux kernel bonding driver:

# cat /proc/net/bonding/bond0 
Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)

Bonding Mode: IEEE 802.3ad Dynamic link aggregation
Transmit Hash Policy: layer3+4 (1)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

802.3ad info
LACP rate: slow
Aggregator selection policy (ad_select): stable
Active Aggregator Info:
    Aggregator ID: 1
    Number of ports: 4
    Actor Key: 17
    Partner Key: 2
    Partner Mac Address: 00:1:e8:d6:6c:2c

Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:1F:4f:a6:f9:51
Aggregator ID: 1
Slave queue ID: 0

Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:1F:4f:a6:f9:52
Aggregator ID: 1
Slave queue ID: 0

Slave Interface: eth2
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:1F:4f:a6:f9:53
Aggregator ID: 1
Slave queue ID: 0

Slave Interface: eth3
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:1F:4f:a6:f9:54
Aggregator ID: 1
Slave queue ID: 0

Check bonding status

Check bonding interface bond0 status

#ifconfig bond0    # ifconfig without specificed interface will show all interfaces

# ifconfig bond0
bond0     Link encap:Ethernet  HWaddr 00:1F4F:A6:F9:50  
          inet addr:192.168.1.1  Bcast:192.168.1.0  Mask:255.255.255.0
          UP BROADCAST RUNNING MASTER MULTICAST  MTU:9000  Metric:1
          RX packets:256657148 errors:0 dropped:0 overruns:0 frame:0
          TX packets:99414757 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:16239517193 (15.1 GiB)  TX bytes:13643055750 (12.7 GiB)

Check bonding and its channel interfaces status, especially you can check if they are balanced being used.

# netstat -i
Kernel Interface table
Iface       MTU Met    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
bond0      9000   0 256655828     0      0      0 99414307      0      0      0 BMmRU
eth0       9000   0  1602235      0      0      0 29241799      0      0      0 BMsRU
eth1       9000   0  3262903      0      0      0 28648713      0      0      0 BMsRU
eth2       9000   0  2075169      0      0      0 20780829      0      0      0 BMsRU
eth3       9000   0 249715523     0      0      0 20742968      0      0      0 BMsRU
lo        65536   0    36713      0      0      0    36713      0      0      0 LRU

 

 

 

 

Comments powered by CComment