Seven modes of Linux NIC Bond

Source: Internet
Author: User
Tags switches

like Samba, NFS This shared file system, the network throughput is very large, resulting in a great pressure on the NIC, Nic Bond is to realize the redundancy of the local network card, bandwidth expansion and load balancing by binding multiple physical network cards into a logical network card, the specific function depends on which mode is adopted.

First, the seven modes of Bond are introduced:
1. Mode=0 (BALANCE-RR) (Balanced rotation strategy)
Link load balancing increases bandwidth, supports fault tolerance, and a link failure automatically switches the normal link. The switch needs to configure the aggregation port, Cisco is called the Port channel.
Features: transmission packet sequence is transmitted sequentially (that is: the 1th packet to go eth0, the next package will go eth1 ....), which provides load balancing and fault tolerance until the last transmission is complete); but we know that if a connection
Or a session of the packet from a different interface, and then through a different link, the client is likely to have a packet out of order to arrive at the problem, and the unordered arrival of the packet needs to be sent again, so that the network throughput will fall

2, Mode=1 (active-backup) (Master-backup policy)
This is the main standby mode, only one network card is active, the other is a spare standby, all traffic is processed on the active link, the switch is configured to bind the words will not work, because the switch to two network card bundle, half of the packet is discarded.
Features: only one device is active, and when one is down the other is converted to the primary device immediately by the backup. The MAC address is externally visible, and from the outside, the MAC address of the bond is unique to avoid the switch from confusing.
This mode only provides fault tolerance, so the advantage of this algorithm is that it can provide high availability of network connection, but its resource utilization is low, only one interface is working, and the resource utilization is 1/n in the case of N network interface.

3, mode=2 (balance-xor) (Balance strategy)
Represents an XOR hash load sharing, and the aggregation of the switch is forced to not negotiate a coordinated manner. (Requires xmit_hash_policy, switch configuration port channel required)
feature: transmits packets based on the specified transfer hash policy. The default policy is: (Source MAC address XOR destination MAC address)% slave number. Other transport policies can be specified through the Xmit_hash_policy option, which provides load balancing and fault tolerance

4, mode=3 (broadcast) (Broadcast policy)
means that all packets are emitted from all network interfaces, which is unbalanced, only redundant, but too wasteful. This mode is suitable for the financial industry because they require a highly reliable network and do not allow any problems. The aggregation of the switch needs to be forced to mate with the non-negotiated mode.
Feature: transmits each packet on each slave interface, which provides fault tolerance

5, Mode=4 (802.3AD) (IEEE 802.3AD dynamic Link aggregation)
Represents support for the 802.3AD protocol, and the aggregation of the Switch LACP mode mates (requires Xmit_hash_ Policy). Standard requires all devices to be in the same rate and duplex mode when aggregating operations, and, as with other bonding load balancing modes other than BALANCE-RR mode, no connection can use more than one interface's bandwidth.
Feature: Create an aggregation group that shares the same rate and duplex settings. Multiple slave are working under the same active aggregate according to the 802.3AD specification. The slave election for outgoing traffic is based on the transfer hash policy, which can be changed from the default XOR policy to other policies through the Xmit_hash_policy option. It is important to note that not all transmission strategies are 802.3ad adapted, and the
especially takes into account the problem of packet chaos mentioned in the 802.3AD standard 43.2.4 section. Different implementations may have different adaptations.
Prerequisites:
Condition 1:ethtool supports obtaining rate and duplex settings for each slave
condition 2:switch (switch) supports IEEE 802.3ad Dynamic link Aggregation
Condition 3: Most switch (switches) require a specific configuration to support 802.3ad mode

6, Mode=5 (balance-tlb) (Adapter transfer load balancer)
is to select slave for each slave load situation to send, using the current turn slave when receiving. This mode requires some kind of ethtool support for the network device driver of the Slave interface, and ARP monitoring is not available.
Features: no special switch (switch) supported channel bonding is required. Out-of-office traffic is allocated on each slave based on the current load (calculated based on speed). If the slave that is accepting data fails, the other slave takes over the MAC address of the failed slave.
Necessary:
Ethtool support for getting the rate per slave

7, Mode=6 (BALANCE-ALB) (Adapter Adaptive load balancer)
RLB (Receive load-balanced receive-load balance) was added on a 5 TLB basis. No switch support is required. Receive load balancing is implemented through ARP negotiation.
Features:This mode includes the BALANCE-TLB mode, plus receive load balancing for IPV4 traffic (receive load balance, RLB), and does not require any switch (switch) support. Receive load balancing is implemented through ARP negotiation. The bonding driver intercepts the ARP response sent by the native and overwrites the source hardware address with the unique hardware address of one of the slave in bond, allowing different peer-to-peer communication using different hardware addresses.
Receive traffic from the server side is also balanced. When the native sends an ARP request, the bonding driver copies and saves the IP information from the ARP packet to the peer. When the ARP response arrives from the peer, the bonding driver extracts its hardware address and initiates an ARP response to one of the slave in Bond.
One problem with the use of ARP negotiation for load balancing is that the hardware address of the bond is used every time the ARP request is broadcast, so when the peer learns the hardware address, the incoming traffic will flow to the current slave. This problem can be resolved by sending updates (ARP responses) to all the peers, which contain their unique hardware address, which results in the redistribution of traffic.
When a new slave is added to bond, or an inactive slave is reactivated, the incoming traffic is also re-distributed. The received load is distributed sequentially (round robin) on the highest speed slave in bond
When a link is re-connected, or a new slave is added to bond, the receive traffic is redistributed in all currently active slave, initiating an ARP reply to each client by using the specified MAC address. The Updelay parameter described below must be set to a value that is greater than or equal to the switch forwarding delay to ensure that the ARP response destined to the peer is not blocked by the switch.
Prerequisites:
The condition 1:ethtool supports obtaining the rate of each slave;
Condition 2: The underlying driver supports setting the hardware address of a device so that there is always a slave (curr_active_slave) using the hardware address of bond, while ensuring that slave in each bond has a unique hardware address. If the curr_active_slave fails, its hardware address will be taken over by the newly elected Curr_active_slave.
In fact, the difference between mod=6 and mod=0: Mod=6, the first eth0 flow accounted for, and then accounted for eth1,....ethx, and mod=0 words, will find that 2 ports of traffic are stable, the same bandwidth. And Mod=6, will find the first port flow is very high, the 2nd port only accounted for a small portion of traffic.


The MODE5 and mode6 do not require switch-side settings, and the NIC can be automatically aggregated. Mode4 needs to support 802.3AD. Mode0,mode2 and mode3 theoretically require a static aggregation method.
However, the MODE0 can be received in the case of MAC address spoofing without the switch being set.

Second, the example of bond configuration
1, first of all to see whether Linux supports bonding, most distributions support

# Modinfo Bonding |morefilename:/lib/modules/2.6.32-431.el6.x86_64/kernel/drivers/net/bonding/bonding.koauthor:        Thomas Davis, [email protected] and many othersdescription:ethernet Channel Bonding Driver, v3.6.0version: 3.6.0license:gplsrcversion:353b1dc123506708446c57bdepends:8021q,ipv6vermagic:2.6.32-431.el6.x 86_64 SMP mod_unload modversions

If the above information is output, the support bonding, if not, the kernel does not support bonding, need to recompile the kernel


Two physical network ports are: Eth0,eth1 the virtual port after binding is: Bond0

[Email protected] ~]# Cat/etc/sysconfig/network-scripts/ifcfg-eth0 device=eth0hwaddr=ec:f4:bb:dc:4c:0ctype= Ethernetuuid=669f0694-9c52-4792-bd67-22c9d2c17acbonboot=yesnm_controlled=nobootproto=nonemaster=bond0slave=yes [Email protected] ~]# cat/etc/sysconfig/network-scripts/ifcfg-eth1device=eth1hwaddr=ec:f4:bb:dc:4c:0dtype= Ethernetuuid=1d2f30f4-b3f0-41a6-8c37-54f03115f7bdonboot=yesnm_controlled=nobootproto=nonemaster=bond0slave=yes [[email protected] ~]# cat/etc/sysconfig/network-scripts/ifcfg-bond0device=bond0name= ' System bond0 ' type=ethernetnm _controlled=nouserctl=noonboot=yesbootproto=noneipaddr=192.168.1.100netmask=255.255.255.0bonding_opts= ' mode=1 Miimon=100 ' Ipv6init=no

Boot auto load module to kernel

#echo ' Alias bond0 bonding ' >>/etc/modprobe.d/dist.conf#echo ' options bonding mode=0 miimon=200 ' >>/etc/mod Probe.d/dist.conf#echo ' ifenslave bond0 eth0 eth1 ' >>/etc/rc.local

miimon=100
Every 100 milliseconds (0.1 seconds) to monitor the state of the road connection, if one line is not connected to another line; The multi-NIC binding feature of Linux uses the "bonding" module in the kernel
If you change to a different mode, you only need to specify Mode=number in Bonding_opts. Userctl=no--whether to allow non-root users to control the device

View bond0 Status: You can see which physical network cards are being called
#cat/proc/net/bonding/bond0

[[email protected] ~]#  cat /proc/net/bonding/ bond0ethernet channel bonding driver: v3.7.1  (april 27, 2011) Bonding  mode: fault-tolerance  (active-backup) Primary slave: nonecurrently active slave:  eth1MII Status: upMII Polling Interval  (ms): 100up delay  (ms):  0Down Delay  (MS): 0slave interface: eth0mii status: upspeed:  1000 MBPSDUPLEX: FULLLINK FAILURE COUNT: 0PERMANENT HW ADDR: EC:F4:BB: dc:4c:0cslave queue id: 0slave interface: eth1mii status: upspeed:  1000 MBPSDUPLEX: FULLLINK FAILURE COUNT: 0PERMANENT HW ADDR: EC:F4:BB: Dc:4c:0dslave queue id: 0 

Third, expansion

The top is two network cards (eth0, eth1) bound into a bond0, if we want to set up a plurality of bond ports, such as the physical network port eth0 and eth1 composition bond0,eth2 and eth3 composition Bond1, then the settings of the network Port settings file and the above
Is the same, just /etc/modprobe.d/dist.conf files can not be superimposed. There are two ways to set up the correct method:
1. The first kind

Alias bond0 bondingalias bond1 bondingoptions bonding max_bonds=2 miimon=200 mode=1

This allows all bindings to use only one mode.

2. The second type

Alias Bond0 bondingoptions bond0 miimon=100 mode=1install bond1/sbin/modprobe bonding-o bond1 miimon=100 mode=0install b Ond2/sbin/modprobe bonding-o bond2 miimon=100 mode=1install bond3/sbin/modprobe bonding-o bond3 miimon=100 mode=0

This way different bond ports can be set to different mode, note the boot automatically start/etc/rc.d/rc.local file settings

Ifenslave bond0 eth0 eth1ifenslave bond1 eth2 eth3ifenslave bond2 eth4 eth5ifenslave bond3 eth6 eth7



This article is from the "Step Into the Linux World" blog, please be sure to keep this source http://linuxnote.blog.51cto.com/9876511/1680315

Seven modes of Linux NIC Bond

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.