Linux dual NIC bindings for load Balancing

Source: Internet
Author: User
Tags switches

System environment: CentOS release 6.9 (Final) Linux centos6 2.6.32-696.10.1.el6.x86_64

Ubuntu system using Ifenslave for network card configuration, the method is similar.

Close NetworkManager
# service NetworkManager stop# chkconfig NetworkManager off
Creating the Bond0 interface configuration file
# cd/etc/sysconfig/network-script/# vim ifcfg-bond0device=bond0ipaddr=192.168 . 100.106 PREFIX=GATEWAY=192.168. 100.1 DNS1=202.103. 24.68 Bootproto=staticonboot=yesuserctl=No
Modifying the configuration of eth0 and eth1
# vim ifcfg-eth0 DEVICE=Eth0bootproto=noneonboot=YesMASTER= Bond0slave=yesuserctl=no
# vim ifcfg-eth1 DEVICE=Eth1bootproto=noneonboot=YesMASTER= Bond0slave=yesuserctl=no
Loading the bonding module
# vim/etc/modprobe. d/bonding.conf #新建bonding. conf file alias bond0 bondingoptions bond0 Miimon=  6 mode=

Description

The Miimon is used for link monitoring. For example:miimon=100, the unit is MS (milliseconds ). Here the 100, is 100ms, that is 0.1 seconds. The system monitors the link connection status every 100ms and transfers to another line if one of the lines is not available. Mode refers to the working pattern, which has a total of seven (0-6). These two parameters can be configured in the/etc/modprobe.d/bonding.conf file, the options bond0 miimon=100 mode=6, or directly in the BOND0 configuration file, bonding_opts= "mode= 6 miimon=100 "

Restart Network Service
# Service Network Restart
ViewBond0 Interface Status
[Email protected] ~]#Cat/proc/net/bonding/bond0 Ethernet Channel Bonding driver:v3.7.1(April -, .) Bonding mode:adaptive load balancingprimary slave:nonecurrently Active slave:eth0mii status:upmii Polling Interva L (MS): -Up Delay (ms):0Down Delay (ms):0Slave interface:eth0mii status:upspeed: -mbpsduplex:fulllink Failure Count:0Permanent HW Addr: the: Wu:xx: A9:4e:2cslave queue ID:0Slave interface:eth1mii status:upspeed: -mbpsduplex:fulllink Failure Count:0Permanent HW Addr: the: Wu:xx: the: 1b: theSlave Queue ID:0

If the bond configuration has been modified several times, the system may need to be restarted and the Bond0 interface status will not be updated.

View network interface send and receive status
1 Ifconfig -A
Seven ways to work with Bond

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 ...). This mode provides load balancing and fault tolerance until the last transmission is complete), but if a connection or session packet is sent from a different interface, After passing through different links, there is a good chance that packets will arrive out of order at the client, and the unordered arrival packets need to be sent again, so the throughput of the network will drop.


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 strategy)

Indicates that all packets are emitted from all network interfaces, this imbalance, only redundant mechanisms, but too wasteful of resources. 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: Each packet is transmitted on each slave interface, and this mode 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 another policy through the xmit_hash_policy option. It is important to note that not all transmission strategies are 802.3AD adapted, especially considering the problem of packet chaos mentioned in the 802.3AD standard 43.2.4 section. Different implementations may have different adaptations.
Necessary:
Conditional 1:ethtool supports getting the rate and duplex settings for each slave
Conditional 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.
Prerequisites: Ethtool supports 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.
Necessary:
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 fault, its hardware address will be newly elected to the Curr_active_slave takeover actually mod=6 and mod=0 difference: mod=6, first eth0 traffic occupied, and then accounted for ETH1,....ETHX; mod= 0, you will find 2 ports of traffic are very 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.

Linux dual NIC bindings for load Balancing

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.