NIC Bonding

最後更新: 2017-06-06

介紹

All bonding interfaces can be configured dynamically by

interacting with and manipulating files under the /sys/class/net/ directory.

 


Step

 

[0] Load channel bonding interface

/etc/modprobe.conf

alias bond0 bonding

[1] Create a Bond0 Configuration File

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

DEVICE=bond0
IPADDR=192.168.1.103
NETWORK=192.168.123.0
NETMASK=255.255.255.0
ONBOOT=yes
# prevent NetworkManager configuring this device
NM_CONTROLLED=no
BONDING_OPTS="bonding parameters separated by spaces"

[2] Modify eth0 and eth1

/etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
ONBOOT=yes
MASTER=bond0
SLAVE=yes
NM_CONTROLLED=no

/etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1
ONBOOT=yes
MASTER=bond0
SLAVE=yes
NM_CONTROLLED=no

[3] Apply Configuration

service network restart

[4] Configuration

cat /proc/net/bonding/bond0

# enable MII monitoring on bond0 with a 1 second interval
echo 1000 > /sys/class/net/bond0/bonding/miimon

# To configure bond0 for balance-alb mode
echo balance-alb > /sys/class/net/bond0/bonding/mode

 


BONDING_OPTS

 

arp_interval=<time_in_milliseconds>

# how often ARP monitoring occurs, 與 arp_ip_target 一起用
# default: 0 <- disable

arp_ip_target=<ip_address>?[,<ip_address_2>,…<ip_address_16>?]

OR

miimon

# MII is used to verify that the NIC is active, default:0 <-- disable
# ethtool <interface_name> | grep "Link detected:"

P.S.

miimon 與 (arp_interval+arp_ip_target) 必須 2 選 1 來用 !!

updelay=<time_in_milliseconds>
# how long to wait before enabling a link. (default: 0)
# multiple of the value specified in the miimon parameter.

primary=eth0
# Specifies the interface of the primary device. active-backup mode

primary_reselect=<value>
# 0(always) (default)
# 1(better)
# 2(failure)

lacp_rate=<value>
# link partners should transmit LACPDU packets in 802.3ad mode

xmit_hash_policy=<value>
 Selects the transmit hash policy used for slave selection in balance-xor and 802.3ad modes.

0 (layer2)      <-- Default # (<source_MAC_address> XOR <destination_MAC>) MODULO <slave_count>
1 (layer3+4)
2 (layer2+3)

Ethernet Bonding Types:

mode=0 (balance-rr)

mode=1 (active-backup)  
# If one interface fails, another interface takes over the MAC address and becomes the active interface.

mode=2 (balance-xor)
based on ((source MAC) XOR (dest MAC))

mode=3 (broadcast)
Transmits everything on all slave interfaces.

mode=4 (802.3ad)[dynamic link aggregation policy]
# Transmits and receives on all slaves in the active aggregator.
# This requires 802.3ad support in the switch.

mode=5 (balance-tlb)[transmit load balancing]
# Incoming traffic is received on the active slave only,
# outgoing traffic is distributed according to the current load on each slave.

mode=6 (balance-alb)[Adaptive Load Balancing]
both transmit load balancing (TLB) and receive load balancing
* require the ability to change the MAC address of a device (achieved through ARP negotiation)

 


Limitations

 

IEEE 802.1aq

 * must reside on the same logical switch

IEEE 802.1aq. The Split multi-link trunking (SMLT) protocol allows multiple Ethernet links to be split across multiple switches in a stack, preventing any single point of failure, and additionally allowing all switches to be load balanced across multiple aggregation switches from the single access stack.

 


Other

 

kernel-doc package: bonding.txt

teaming