linux--7 Types of bond modes for multiple NICs

Source: Internet
Author: User
Tags switches

Network card bond is to realize the redundancy, bandwidth expansion and load balance of the local NIC by binding the multi-net cards into a logical network card. In the application deployment is a commonly used technology, our company basic all the project related servers have done bond, here summarized and collated, in order to unknown origin.

Bond mode:

    1. Mode=0 (BALANCE-RR) represents the load sharing round-robin, and the aggregation of the switch is forced to mate in a manner that does not negotiate.
    2. Mode=1 (active-backup) means that the main standby mode, only one network card is active, the other piece is prepared standby, at this time if the switch with the bundle is tied, will not work, because the switch to two network card bundle, half of the packet is discarded.
    3. mode=2 (Balance-xor) represents an XOR hash load sharing, and the aggregation of the switch is forced to not negotiate a coordinated manner. (Requires Xmit_hash_policy)
    4. Mode=3 (broadcast) indicates that all packages are emitted from all interface, this unbalanced, only redundant mechanism ... And the aggregation of the switch is forced to not negotiate the way mates.
    5. Mode=4 (802.3AD) indicates support for 802.3AD protocol, and the aggregation of the switch LACP-mode mates (requires Xmit_hash_policy)
    6. Mode=5 (balance-tlb) is selected slave based on the load situation of each slave to send, using the current turn slave when receiving
    7. Mode=6 (BALANCE-ALB) added RLB on the 5 tlb basis.

5 and 6 do not require the switch-side settings, the network card can be automatically aggregated. 4 Need support 802.3AD. 0,2 and 3 theoretically require a static aggregation method
However, the actual measurement of 0 can be fooled by the MAC address in the case of the switch does not set the situation is not too balanced to receive.

There are three kinds of common

Mode=0: Balanced load mode with automatic redundancy, but requires "Switch" support and settings.

Mode=1: Automatic redundancy mode, where one line is disconnected, other lines will be automatically redundant.

MODE=6: Balanced load mode with automatic redundancy without "Switch" support and settings.

It is important to note that if you want to make mode 0 load balancer, just set the options bond0 miimon=100 mode=0 is not enough, the switch connected to the NIC must do a special configuration (these two ports should be aggregated), Because the two NICs that do bonding are using the same MAC address. From the principle analysis (bond runs under mode 0):

Mode 0 under Bond the IP of the NIC is changed to the same MAC address, if these network cards are connected to the same switch, then the switch ARP table this MAC address corresponds to a number of ports, then the switch to the MAC address to accept the packet to which port to forward it? Normally the MAC address is the only one in the world, and a MAC address that corresponds to multiple ports definitely confuses the switch. So mode0 bond If you connect to the switch, these ports of the switch should be aggregated (Cisco is called Ethernetchannel,foundry called PortGroup), since the switches are aggregated, Several ports under aggregation are also bundled into a MAC address. Our solution is to have two NICs connected to different switches.

There is no need to configure the switch in Mode6 mode, because the two NICs that do bonding use different MAC addresses.

Linux Network Port Bindings

Through the network port binding (bond) technology, can easily realize the network port redundancy, load balancing, so as to achieve high availability and high reliability. Prerequisite Agreement:

2 Physical network ports are: eth0,eth1

The virtual port after binding is: Bond0

The server IP is: 192.168.0.100

The first step is to configure the settings file:

/etc/sysconfig/network-scripts/ifcfg-bond0

Device=bond0

Bootproto=none

Onboot=yes

ipaddr=192.168.0.100

netmask=255.255.255.0

network=192.168.0.0

broadcast=192.168.0.255

#BROADCAST广播地址

/etc/sysconfig/network-scripts/ifcfg-eth0

Device=eth0

Bootproto=none

Master=bond0

Slave=yes

/etc/sysconfig/network-scripts/ifcfg-eth1

Device=eth1

Bootproto=none

Master=bond0

Slave=yes

The second step is to modify the Modprobe related settings file and load the bonding module:

1. Here, we create a dedicated setup file that loads bonding/etc/modprobe.d/bonding.conf

[Email protected] ~]# vi/etc/modprobe.d/bonding.conf

#追加

Alias Bond0 Bonding

Options Bonding Mode=0 miimon=200

2. Load the module (reboot the system without manually reloading)

[Email protected] ~]# modprobe bonding

3. Confirm that the module is loaded successfully:

[Email protected] ~]# Lsmod | grep bonding

Bonding 100065 0

The third step, restart the network, and then confirm the situation:

[Email protected] ~]#/etc/init.d/network restart

[Email protected] ~]# cat/proc/net/bonding/bond0

Ethernet Channel Bonding driver:v3.5.0 (November 4, 2008)

Bonding mode:fault-tolerance (Active-backup)

Primary Slave:none

Currently Active Slave:eth0

......

[Email protected] ~]# Ifconfig | grep HWaddr

Bond0 Link encap:ethernet HWaddr 00:16:36:1b:bb:74

Eth0 Link encap:ethernet HWaddr 00:16:36:1b:bb:74

eth1 Link encap:ethernet HWaddr 00:16:36:1b:bb:74

From the confirmation information above, we can see 3 important information:

1. Now the bonding mode is Active-backup

2. Now the active state of the network port is eth0

The physical address of the 3.bond0,eth1 is the same as the physical address of the eth0 in the active state, in order to avoid confusion on the upper switch.

Unplug a network cable and then visit your server to see if the Internet is still on.

In the fourth step, the system starts auto-binding and adds the default gateway:

[Email protected] ~]# vi/etc/rc.d/rc.local

#追加

Ifenslave bond0 eth0 eth1

Route add default GW 192.168.0.1

#如可上网就不用增加路由, 0.1 addresses are modified by environment.

------------------------------------------------------------------------

Note: The front is just 2 network ports bound into a bond0 case, if we want to set up a plurality of bond ports, such as physical network port eth0 and eth1 composition bond0,eth2 and eth3 composition Bond1,

Then the setting of the network settings file method and the 1th step above the same method, but the/etc/modprobe.d/bonding.conf settings can not be as simple as the following overlay:

Alias Bond0 Bonding

Options Bonding mode=1 miimon=200

Alias Bond1 Bonding

Options Bonding mode=1 miimon=200

There are 2 ways to set up the correct method:

First, you can see that, in this way, multiple bond-port patterns can only be set to the same:

Alias Bond0 Bonding

Alias Bond1 Bonding

Options bonding max_bonds=2 miimon=200 mode=1

Second, in this way, the mode of the different bond openings can be set differently:

Alias Bond0 Bonding

Options Bond0 miimon=100 mode=1

Install Bond1/sbin/modprobe bonding-o bond1 miimon=200 mode=0

Take a closer look at the above 2 Setup methods, now if you want to set 3, 4, or even more bond port, you should also have it!

PostScript: A brief introduction to the above when loading the bonding module, the options in the meaning of some parameters:

Miimon monitors the frequency of network links in milliseconds, which we set to 200 milliseconds.

Max_bonds number of bond ports configured

Mode bond model, in general practical applications, 0 and 1 are used more,

linux--7 Types of bond modes for multiple NICs

Related Article

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.