--ubuntu16.04 dual NIC binding due to project needs

Source: Internet
Author: User

Official Document: Https://help.ubuntu.com/community/UbuntuBonding


Binding, also known as Port aggregation or link aggregation, means that multiple network interfaces (NICs) are combined into a single link, providing high availability, load balancing, maximum throughput, or these combinations. Please refer to Wikipedia for details.


1. Installation

sudo apt-get install Ifenslave


2. Ensure kernel support

Before Ubuntu can configure the NIC as a NIC binding, you need to ensure that the correct kernel module bindings are present and loaded at boot time.


To edit your/etc/modules configuration:

sudo vim/etc/modules


Make sure the bonding module is loaded

#/etc/modules:kernel modules to load at boot time.

#

# This file contains the names of kernel modules, should be loaded

# at boot time, one per line. Lines beginning with "#" is ignored.

Loop

Lp

Rtc

Bonding


Note: Starting with Ubuntu 9.04, this step is optional if you use Ifup/ifdown to configure bindings. In this case, when the binding interface is lifted, the binding module is loaded automatically.


3. Configure the network interface

Make sure your network is turned off:

/etc/init.d/networking stop


Then load the binding kernel module:

sudo modprobe bonding


You are now ready to configure your NIC.

The general guiding principles are:

1. Select which of the available NICs will be part of Bond.

2. Configure all other NICs as usual

3. Configure all the bundled NICs:

1. To manually configure

2, join the designated Bond-master

4, configure the NIC as if it is a normal network card

5. Add binding specific parameters to the bound Nic as shown below.


To edit your interface configuration:

sudo vi/etc/network/interfaces


For example, to use simple active backup settings, eth0 and eth1 as active-backup to bonding interface bond0 and eth0 as the primary interface:



The Ethernet bindings can use different modes. You can specify the mode of your binding interface in/etc/network/interfaces. For example:

Bond-mode 1


Bonding There are 7 different modes of operation

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.

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.

2: (Balance-xor) XOR policy: (Balanced 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.

3: (broadcast) broadcast policy: (Broadcast policy): Transfers all packets to all devices. This mode provides fault tolerance.

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.

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.

6: (BALANCE-ALB) Adaptive load Balancing: (Adapter Load Balancer): Includes MODE5, the payload that is received by the 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.


What if it's multiple bond? (tested, no need for this step is possible)

If there is more than one bond, such as:

Eth0 and eth1 make a bond0

Eth1 and eth2 make a bond1

Then you need to change the contents of/etc/modules to:

Bonding mode=1 miimon=100 max_bonds=2

That is to add a max_bonds=2 on the original basis.

The NIC configuration section is the same as bond0, except that the eth0 and eth1 in the configuration are changed to Eth2 and Eth3.

Finish.


Failure Test Results:

Situation 1:eth0 as the main, eth1 as preparation, eth0 broken off, will automatically switch to eth1, such as eth0 after recovery, the wiring sequence is: First unplug eth1, then immediately plug in eth0, then eth1 back


Test environment configuration file:

[Email protected]:~# cat/etc/network/interfaces

# This file describes the network interfaces available on your system

# and how to activate them. For more information, see Interfaces (5).


source/etc/network/interfaces.d/*


# The Loopback network interface

Auto Lo

Iface Lo inet Loopback


# The Primary network interface

Auto Ens33

Iface Ens33 inet Manual

Bond-master bond0

Bond-primary Ens33


Auto ENS34

Iface ens34 inet Manual

Bond-master bond0



Auto ENS35

Iface ENS35 inet Manual

Bond-master Bond1

Bond-primary ENS35


Auto ENS36

Iface ens36 inet Manual

Bond-master Bond1


Auto Bond0

Iface bond0 inet Static

Address 192.168.89.160

Gateway 192.168.89.2

Netmask 255.255.255.0

Bond-mode Active-backup

Bond-miimon 100

Bond-slaves None


Auto Bond1

Iface bond1 inet Static

Address 192.168.68.144

Netmask 255.255.255.0

Bond-mode Active-backup

Bond-miimon 100

Bond-slaves None





--ubuntu16.04 dual NIC binding for project needs

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.