Ubuntu Configure dual NIC bindings for load Balancing

Source: Internet
Author: User

Ubuntu Configure dual NIC bindings for load Balancing 1, bond working mode

The Linux bonding driver provides a bundle of multiple network interface devices into a single network interface setting for Network Load Balancing and network redundancy.

Bonding there are altogether 7 modes of operation:

    • 1), Bond=0, (BALANCE-RR) round-robin policy: (Balanced polling strategy): The transmit packet order is transmitted sequentially until the last transmission is complete, which provides load balancing and fault tolerance.

    • 2), bond=1, (active-backup) active-backup policy: (Active backup policy): Only one device is active. One goes down and the other immediately transforms the primary device from the backup. The MAC address is externally visible. This mode provides fault tolerance.

    • 3), bond=2, (Balance-xor) XOR policy: (Balancing strategy): transmits a transmission device based on a Boolean value [(Source MAC address Xor destination MAC address) mod device number]. This mode provides load balancing and fault tolerance.

    • 4), Bond=3, (broadcast) broadcast policy: (Broadcast policies): Transfer all packets to all devices. This mode provides fault tolerance.

    • 5), bond=4, (802.3AD) IEEE 802.3ad Dynamic link aggregation. IEEE 802.3ad Dynamic Link aggregation: Create an aggregation group that shares the same speed and duplex settings. This mode provides fault tolerance. Each device requires drive-based re-acquisition speed and full-duplex support, and if the switch is used, the switch also needs to enable 802.3AD mode.

    • 6), bond=5, (balance-tlb) Adaptive Transmit load balancing (adapter transport load balancer): Channel bindings do not require dedicated switch support. The traffic emitted is assigned to each device according to the current load. Received by the current device, if the accepted device does not pass, use another device to take over the MAC address that the current device is processing.

    • 7), bond=6, (BALANCE-ALB) Adaptive load Balancing: (Adapter Load Balancer): Includes MODE5, the payload that is received by ARP negotiation. The bonding driver intercepts the request sent by ARP on the local system, overwriting the original address of the subordinate device with one of the hardware addresses. It's like a different person on the server using a different hardware address.
2. Configuration steps

The following steps are the same for configuring the Bond=6 two-Nic binding step, as in other modes;

2.1. Installing Ifenslave Software

The Fenslave is a bonded and decoupled software that efficiently distributes packets to the bonding drive

sudo apt install ifenslave
2.2./etc/modules File

Add the following configuration to the/etc/modules file

bonding mode=6 miimon=100

Mode=6 means mode 1;
The Miimon is used for link monitoring. For example, miimon=100, the system is monitored every 100ms link connection status, if one line is not available to switch another line.

2.3. Modify/etc/network/interfaces File Configuration

First need to determine the name of the NIC interface, can be viewed through the ifconfig command, is currently the NIC interface is ENS33 and ens34; Add the following configuration in the/etc/network/interfaces file

# 双网卡配置auto ens33iface ens33 inet manualbond-master bond0auto ens34iface ens34 inet manualbond-master bond0auto bond0iface bond0 inet staticaddress 192.168.20.10netmask 255.255.255.0gateway 192.168.20.2dns-nameservers 192.168.20.1 119.29.29.29bond-slaves ens33 ens34bond-lacp-rate 1bond-mode 6bond-miimon 100
2.4. Loading the binding module
#  载入模块$ sudo modprobe bonding# 查看模块,如果模块已经加载,显示出来$ sudo lsmod|grep bondingbonding               163840  0
2.5. View status
    • View network Configuration
$ ifconfigbond0 Link EnCap: Ethernet Hardware address 00:0c:29:34:7a:4a inet address: 192.168.20.10 Broadcast: 192.168.20.255 Mask: 255.255.255.0 inet6 Address: fe80::20c:29ff:fe34:7a4a/64 scope:link up broadcast RUNNING MASTER Multicast mtu:1500 hops: 1 Receive packet: 964 Error: 0 Discard: 0 Overload: 0 Number of frames: 0 Send packet: 4205 error: 0 Discard: 0 Overload: 0 Carrier: 0 Collisions: 0 Send Queue Length: 1000 bytes Received: 75022 (75.0 kb) Send bytes: 300032 (300.0 kb) ens33 Link ENCAP: Ethernet Hardware Address 00:0c:29:34:7a:4a Up broadcast RUNNING SLAVE multicast mtu:1500 hop count: 1 Receive packet: 2740 Error: 0 Discard: 0 Overload: 0 Number of frames: 0 Send packet: 3416 error: 0 Discard: 0 Overload: 0 Carrier: 0 Collisions: 0 Send Queue Length: 1000 Receive bytes: 3899473 (3.8 MB) Send bytes: 278409 (278.4 KB) ens34 Link ENCAP: Ethernet Hardware Address 00:0c:29:34:7a:54 Up broadcast RUNNING SLAVE multicast mtu:1500 hop count: 1 Receive packet: 1369 error: 0 Discard: 0 Overload: 0 Number of frames: 0 Send packet: 2125 error: 0 Discard: 0 Overload: 0 Carrier: 0 Collisions: 0 Send Queue Length: 1000 Receive bytes: 106846 (106.8 kb) Send bytes: 139061 (139.0 KB) 
    • View binding Status
$ cat /proc/net/bonding/bond0 Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)Bonding Mode: adaptive load balancingPrimary Slave: NoneCurrently Active Slave: ens33MII Status: upMII Polling Interval (ms): 100Up Delay (ms): 0Down Delay (ms): 0Slave Interface: ens33MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: 00:0c:29:34:7a:4aSlave queue ID: 0Slave Interface: ens34MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: 00:0c:29:34:7a:54Slave queue ID: 0
2.6. Verification Test
    • Physically turn off a network card (unplug the network cable)
# before closing, the rate is 2000mb/s$ ethtool bond0settings for bond0:supported ports: [] Supported link Modes:not reported supported pause frame use:no Supports auto-negotiation:no advertised link Modes:not rep Orted advertised Pause frame use:no advertised Auto-negotiation:no speed:2000mb/s duplex:full Port:oth Er phyad:0 transceiver:internal auto-negotiation:offcannot get Wake-on-lan settings:operation not permitted When Link detected:yes# is off, the rate rate becomes 1000mb/s$ ethtool bond0settings for bond0:supported ports: [] Supported link modes : not reported supported pause frame use:no Supports auto-negotiation:no advertised link Modes:not reported Advertised pause frame use:no advertised Auto-negotiation:no speed:1000mb/s duplex:full port:other phyad:0 transceiver:internal Auto-negotiation:offcannot Get Wake-on-lan settings:operation not permitted Lin K Detected:yes 

Note: You may not use Ifdown to turn off the network card, which can cause

3. Summary

Linux bonding There are altogether 7 modes of operation, if you want to increase the throughput of the network card, usually use the mode=6 mode, if the network is stable, usually use the mode=1 mode;

Ubuntu Configure 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.