Deep Analysis 7 Bond mode principle of seven mode multi-NIC with dual NIC binding in Linux

Source: Internet
Author: User

http://blog.csdn.net/abc_ii/article/details/9991845

7 Bond mode principles for multiple NICs Linux NIC bindings mode A total of seven kinds (0~6) bond0, Bond1, Bond2, Bond3, Bond4, Bond5, Bond6 There are three types of 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 should be explained that if you want to make mode 0 load balancer, just set the options bond0 Miimon= -Mode=0 is not enough, the switch connected to the NIC must do a special configuration (both ports should be aggregated), because the two NICs that do bonding are using the same MAC address. Analyze from the principle (bond runs under mode 0): mode 0 The IP of the NIC bound by Bond is modified 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 accept the packet destined to this MAC address 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. Seven bond modes describe the first mode: MoD=0, namely: (BALANCE-RR) round-Robin policy (balanced rotation cycle strategy) features: The transmission packet sequence is transmitted sequentially (i.e.: the 1th packet goes eth0, the next packet goes eth1 ....), which is cycled until the last transmission is complete), this mode provides load balancing and fault tolerance But we know that if a connection or session packet is sent from a different interface, and then passes through a different link, there is a good chance that the packet will arrive out of order at the client, and the unordered arrival packet needs to be sent again, so the throughput of the network will fall down the second mode: MoD=1, namely: (Active-backup) active-backup policy (Master-backup strategy) features: Only one device is active when one is down and the other is converted to the primary device immediately. 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 network connectivity availability, but its resource utilization is low, only one interface is working, in the case of N network interfaces, the resource utilization is 1/N Third mode: MoD=2, namely: (balance-xor) XOR Policy (Balancing Strategy) features: transmits packets based on the specified transfer hash policy. The default policy is: (Source MAC address XOR destination MAC address)%number of slave. Other transport policies can be specified by the Xmit_hash_policy option, which provides load balancing and fault tolerance in the fourth mode: MoD=3, that is: Broadcast (broadcast policy) feature: Each packet is transmitted on each slave interface, and this mode provides a fault tolerance of the fifth mode: MoD=4, namely: (802.3ad) IEEE802.3ad Dynamic Link Aggregation (IEEE802. 3AD dynamic Link aggregation) 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 802.3AD standard.2. 4 The problem of packet chaos mentioned in the chapter. Different implementations may have different adaptations. Prerequisites: Conditional 1:ethtool supports obtaining the rate and duplex setting conditions for each slave 2:Switch(switch) supports IEEE802. 3ad Dynamic Link Aggregation condition 3: Most switches require a specific configuration to support the sixth mode of 802.3AD mode: MoD=5, namely: (balance-tlb) Adaptive Transmit load balancing (adapter transport load Balancer) feature: No special 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. Required for this mode: Ethtool supports getting the rate of each slave seventh mode: MoD=6, namely: (balance-Alb) Adaptive Load Balancing (adapter adaptive Load Balancer) Features: This mode contains the balance-tlb mode, plus receive load balancing for IPV4 traffic (receive load balance, RLB), and no switch support is required. 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) in bond with the highest speed slave a link is re-connected, or a new slave is added to bond, receiving traffic is redistributed in all currently active slave, by using the specified MAC address to each The client initiates an ARP reply. 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: Conditional 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 each bond has a unique hardware address in the slave. If the curr_active_slave fails, its hardware address will be taken over by the newly elected Curr_active_slave modThe difference between =6 and mod=0: mod=6, first of all eth0 flow accounted for, and then accounted for eth1,....ethx, and mod=0 words, you will find that the flow of 2 ports are very stable, the basic same bandwidth. and mod=6, will find the first port traffic is very high, the 2nd port only accounted for a small portion of traffic Linux network port binding 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: 2 Physical network ports are: Eth0,eth1 after binding the virtual port is: Bond0 server IP is:192.168.0.100The first step is to configure the settings file:/etc/sysconfig/network-scripts/ifcfg-Bond0device=Bond0bootproto=Noneonboot=yesipaddr=192.168.0.100NETMASK=255.255.255.0NETWORK=192.168.0.0Broadcast=192.168.0.255#BROADCAST广播地址/etc/sysconfig/network-scripts/ifcfg-Eth0device=Eth0bootproto=Nonemaster=Bond0slave=Yes/etc/sysconfig/network-scripts/ifcfg-Eth1device=Eth1bootproto=Nonemaster=Bond0slave=Yes the second step, modify the Modprobe related settings file, and load the bonding module:1Here, we directly create a dedicated setup file that loads bonding/etc/modprobe.d/Bonding.conf[[email protected]~]# vi/etc/modprobe.d/bonding.conf# Append alias bond0 bondingoptions bonding mode=0miimon= $2Load Module (no manual reload after rebooting the system) [email protected]~]# modprobe Bonding3confirm that the module is loaded successfully: [[email protected]~]# Lsmod |grep bondingbonding100065 0The third step, restart the network, and then confirm the status: [[email protected]~]#/etc/init.d/network Restart[[email protected]~]# cat/proc/net/bonding/bond0ethernet Channel Bonding driver:v3.5.0(November4, -) Bonding Mode:fault-tolerance (active-backup) Primary slave:nonecurrently Active Slave:eth0 ... [[Email protected]~]# Ifconfig |grep HWaddrbond0 Link encap:ethernet HWaddrxx: -: $: 1B:BB: Abouteth0 Link encap:ethernet HWaddrxx: -: $: 1B:BB: Abouteth1 Link encap:ethernet HWaddrxx: -: $: 1B:BB: Aboutfrom the confirmation information above, we can see 3 important information:1. Now the bonding mode is active-Backup2the network port of the active state is now eth03The physical address of the . 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. Fourth, the system starts the automatic binding, adds the default gateway: [[email protected]~]# vi/etc/rc.d/rc.local# Append ifenslave bond0 eth0 eth1route AdddefaultGw192.168.0.1#如可上网就不用增加路由,0. 1 addresses are modified by environment.------------------------------------------------------------------------Note: The front is only 2 network port binding into a bond0 case, if we want to set up a number of bond ports, such as physical network port eth0 and eth1 composition bond0,eth2 and eth3 composition Bond1, then the settings of the network Port settings file and the 1th step of the same method, Just/etc/modprobe.d/The bonding.conf setting cannot be stacked as simple as the following: alias bond0 bondingoptions Bonding mode=1miimon= $alias Bond1 bondingoptions bonding mode=1miimon= $There are 2 ways to set up the right way: the first, you can see, in this way, multiple bond port patterns can only be set to the same: alias bond0 bondingalias bond1 bondingoptions Bonding max_bonds =2miimon= $Mode=1second, in this way, the mode of the different bond ports can be set differently: Alias Bond0 bondingoptions bond0 Miimon= -Mode=1Install Bond1/sbin/modprobe Bonding-o Bond1 miimon= $Mode=0Take 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 in the load bonding module, the options in the meaning of some parameters: Miimon monitor the frequency of network links, the unit is milliseconds, we set the 200 milliseconds. Max_bonds configuration of the number of bond port mode bond model, mainly the following, in the general practical application, 0 and 1 with more, if you want to understand the characteristics of these patterns will need to rely on the reader yourself to check the information and practice. Multi-nic binding plots1, log in with the root user2, take a look at the IP address with the ifconfig command, and see if eth0 and eth1 get to the IP address (because the Linux server is connected to a DHCP server) and see the IP address as eth016.157.125.78Eth116.157.125.113Broadcast:16.157.125.255Mask:255.255.254.0(eth0 and eth1 are both this broadcast and mask)3, edit the virtual network interface configuration file, and specify the NIC IPVI/etc/sysconfig/network-scripts/ifcfg-bond0 Creating a virtual network interface configuration file4, [[Email protected] -root]# cp/etc/sysconfig/network-scripts/ifcfg-eth0 ifcfg-bond0 Copy the configuration file inside the Ifcfg-eth0 to ifcfg-bond0 inside and use VI ifcfg.-The bond0 command modifies the virtual configuration port. 5, modify the first line device=bond0, then change the configuration to eth0 configuration (the diagram below) Click here to view the picture in a new window6, use the Cat command to view the configuration of eth0 and eth1 Click here to browse the pictures in a new window7, # vi/etc/modules.conf Edit/etc/modules.conf file, add the following line to enable the system to load the bonding module at startup Click here to view the picture in a new window8, add the following two lines alias bond0 bonding options Bond0 Miimon= -Mode=1Note: The Miimon is used for link monitoring. For example: Miimon= -, then the system every 100MS monitoring link connection status, if one line is not connected to another line; The value of mode indicates the mode of operation, which he shared0,1,2,3Four modes, commonly used for0,1two kinds. Mode=0Represents load Balancing (round-Robin) is a load-balanced approach, with both NICs working. Mode=1Represents Fault-tolerance (active-Backup) provides redundancy, working in a way that the master works, which means that only one NIC works by default, and the other is backed up. Bonding can only provide link monitoring, i.e. whether the link from the host to the switch is connected.  If only the switch's external link is down, and the switch itself does not fail, then bonding will assume that the link is not a problem and continue to use it. Click here to browse the picture in a new window9, # vi/etc/rc.d/rc.local Click here to browse the picture in a new windowTen, add two lines ifenslave bond0 eth0 eth1 route add-net16.157.125.255Netmask255.255.255.0Bond0 added: Click here to browse the picture in a new window One, reboot post time look red box inside to succeed. Click here to browse the picture in a new window A, you can enter the system to check the IP on it. Click this in the new window to browse the picture can be seen bond0 has been obtained to eth0 initialization address, and eth0 and Eth1 MAC address are the same, that two block has been bound to a network card.

Deep Analysis 7 Bond mode principle of seven mode multi-NIC with dual NIC binding in Linux

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.