Linux bonding can bond multiple network interfaces into one network interface to achieve network load balancing and network redundancy. Even if one of the physical NICs fails, it will not cause the network to be disconnected.
Linux Bonding has 7 modes.
|mode = 0||balance-rr||Round-robin policy||The packets are transmitted sequentially in the order of the device until the last device. This mode provides load balancing and fault tolerance.|
|mode = 1||active-backup||Active-backup policy||Only one NIC is active, and the other NICs are standby. When the active NIC is fault, and another standby NIC is immediately converted to the primary device. The mac address is externally visible. This mode provides fault tolerance.|
|mode = 2||balance-xor||XOR policy||The transmission device is selected based on the result of the MAC address exclusive XOR operation. This mode provides load balancing and fault tolerance.|
|mode = 3||broadcast||Broadcast policy||All data packets are transmitted to all interfaces, all data is transmitted through all devices. This mode provides fault tolerance.|
|mode = 4||802.3ad||IEEE 802.3ad Dynamic link aggregation||Share the same transfer speed by creating aggregate groups. This mode requires the switch to support 802.3ad mode. This mode provides fault tolerance.|
|mode = 5||balance-tlb||Adaptive transmit load balancing||The data to be sent is distributed to each device according to the current load, and the received data is processed by the currently used device. This mode provides load balancing and fault tolerance.|
|mode = 6||balance-alb||Adaptive load balancing||This mode includes the balance-tlb mode and increases the receive load balance (rlb) for IPV4. Receive load balance is implemented through ARP negotiation. The bonding driver intercepts the ARP reply sent by the local machine and rewrites the source hardware address to the unique hardware address of a slave in the bond.|
Bond the em1 and em2 NIC ports to bond0.
The NIC port name of the Dell server is em1, em2, etc. The name of the NIC port of the Linux system is often eth0, eth1, etc.
# vim /etc/network/interfaces
You do not need to configure the em1, em2 port information, you just need to configure the IP address and other information on the Bond(bond0).
Add to file.
# modprobe bonding
bond0 can be created automatically after reboot.
You can manually create and delete bond0 by editing the file
Create a new Bond(bond0):
# echo +bond0 > /sys/class/net/bonding_masters
Delete a exist Bond(bond0):
# echo -bond0 > /sys/class/net/bonding_masters
Show all Bonds:
# cat /sys/class/net/bonding_masters
You can make port belong to bond by editing the file
Make port em1, em2 belong to bond0:
# echo +em1 > /sys/class/net/bond0/bonding/slaves
Release Slave(em1,em2) from Bond(bond0):
# echo -em1 > /sys/class/net/bond0/bonding/slaves
After adding the em1, em2 port to the
bond0, you can temporarily access the Internet (the network will disconnected again after the restart), so install the
# apt-get update
Now, the network will always be connected, even if you reboot later.
up means successful:
MII Status: up
down means not enabled, there may be not automatically enabled, you can try to start it manually:
ifconfig bond0 up