RedHat allows administrators to bind multiple NICs to one channel to achieve load balancing or fault tolerance.
Interfaces), Linux comes with the bonding driver after kenrnel2.4.12. You can also run the following command to check whether the kernel supports
Bonding:
# Cat/boot/config-kernel-version | grep-I Bonding
Config_bonding = m
Return
Config_bonding = m indicates support; otherwise, the kernel must be compiled to support bonding.
Take redhat5.1 as an example. Assume that we have two NICs, eth0 and eth1. We need to bind these two NICs to achieve load balancing or failure protection.
Step 1: Create an ifcfg-bondx
# Touch/etc/sysconfig/network-scripts/ifcfg-bond0
# Vi/etc/sysconfig/network-scripts/ifcfg-bond0
Device = bond0
Bonding_opts = "mode = 1 miimon = 500"
Bootproto = none
Onboot = Yes
Broadcast = 192.168.0.255
Ipaddr = 192.168.0.180
Netmask = 255.255.255.0
Network = 192.168.0.0
Userctl = No
Edit ifcfg-bond0 as above, where:
Device = bond0 specify the device name as bond0
Bonding_opts = "mode = 1 miimon = 500" where mode has multiple modes to implement different functions, among which 1, 5, 6 do not require special switch configuration, the vswitches 0, 2, 3, and 4 need to be configured to fully implement the corresponding functions. We use the most 0 and 1 modes:
0. balancerr or 0: Server Load balancer is enabled. Two NICs work at the same time. When one of the NICS goes down, the other will continue to work.
1. Active-backup or 1: active/standby mode. Only one Nic works. When one of the NICS fails, the other Nic takes over and starts to work.
For more information about the other modes, see the reposted howto do Linux Ethernet bonding drive.
R
Step 2: Modify/etc/sysconfig/ifcfg-ethx
Ethx refers to the name of the ENI to be bound. In this example, It is eth0 and eth1.
# Vi/etc/sysconfig/ifcfg-eth0
DEVICE=eth0 BOOTPROTO=none ONBOOT=yes MASTER=bond0 SLAVE=yes USERCTL=no
# Vi/etc/sysconfig/ifcfg-eth1
DEVICE=eth1BOOTPROTO=none ONBOOT=yes MASTER=bond0 SLAVE=yes USERCTL=no
Step 3: Configure/etc/modprobe. conf and add alias bond0 Bonding
# Vi/etc/modprobe. conf
Alias eth0 pcnet32
Alias eth1 pcnet32
Alias scsi_hostadapter mptbase
Alias scsi_hostadapter1 mptspi
Alias bond0 Bonding
Step 4: restart the network service
# Service network restart
With the above four steps, bond0 should take effect and work properly. You can run the ifconfig command to check whether the port is normal. You can also view/proc/NET/Bonding/bond0 to check the current mode, which Nic is currently working.
# Cat/proc/NET/Bonding/bond0
Ethernet channel bonding DRIVER: v3.0.3 (March 23,200 6)
Bonding mode: Fault-Tolerance (Active-Backup)
Primary slave: None
Currently active slave: eth0
MII status: Up
MII polling interval (MS): 500
Up delay (MS): 0
Down delay (MS): 0
Slave interface: eth0
MII status: Up
Link failure count: 0
Permanent hw addr: 00: 0C: 29: 01: 4f: 77
Slave interface: eth1
MII status: Up
Link failure count: 0
Permanent hw addr: 00: 0C: 29: 01: 4f: 8b