Linux multi-NIC load balancing: Bond

Source: Internet
Author: User

In this introduction of the Linux dual-NIC binding implementation is the use of two network card virtual become a network card, the aggregation of the device appears to be a separate Ethernet interface device, popular point is that two network cards with the same IP address and parallel link aggregation into a logical link work. In fact, this technology has long existed in sun and Cisco, known as Trunking and EtherChannel technology, which is also used in the Linux 2.4.x kernel, known as bonding. The earliest application of bonding technology was designed to improve the data transmission between cluster nodes in the cluster--beowulf. Let's discuss the principle of bonding, what is bonding needs to start with the promiscuous (PROMISC) mode of the NIC. We know that under normal circumstances, the network card only receives the destination hardware address (MAC addresses) is the Ethernet frame of its own Mac, filtering out other data frames to reduce the burden on the driver. But the NIC also supports another mode called promiscuous Promisc, which can receive all the frames on the network, such as Tcpdump, which is running in this mode. Bonding also runs in this mode, and modifies the MAC address in the driver, changing the MAC address of the two NIC to the same, and receiving data frames for a particular Mac. The corresponding data frames are then routed to the bond driver for processing.

In fact, in Linux to bind the dual network adapter into a network card, the configuration is very simple, just a few steps can be achieved, let's take a look at it. First of all, we will make a brief introduction to the environment of this experiment:

Operating system: RedHat Enterprise Linux

Binding Prerequisites: The chipset model is the same, and the NIC should have its own independent BIOS chip.

Operation Process:

1, edit the virtual network interface configuration file, specify the network card IP (without this file we can copy one from the previous configuration file, reduce the input text.)

[Root @heng ~] # cp/etc/sysconfig/network-scripts/ifcfg-eth0/etc/sysconfig/network-scripts/ifcfg-bond0


Make sure the/etc/sysconfig/network-scripts/ifcfg-bond0 content is the same as the following

[Root @heng ~] # cat/etc/sysconfig/network-scripts/ifcfg-bond0
device=bond0
Bootproto=static
broadcast=192.168.1.255
ipaddr=192.168.1.202
netmask=255.255.255.0
Onboot=yes
Type=ethernet


2. Edit/etc/sysconfig/network-scripts/ifcfg-eth0 and/etc/sysconfig/network-scripts/ifcfg-eth1 to make sure the edited content is the same as shown below

[Root @heng ~] # Cat/etc/sysconfig/network-scripts/ifcfg-eth0
Device=eth0
Onboot=yes
Bootproto=none

Type=ethernet

Master=bond0

Slave=yes


[Root @heng ~] # cat/etc/sysconfig/network-scripts/ifcfg-eth1
Device=eth1
Onboot=yes
Bootproto=none

Type=ethernet

Master=bond0

Slave=yes

3, edit the/etc/modprobe.conf or/etc/modprobe.d/dist.conf file, add the following line to enable the system to load the bonding module at startup, the external virtual network interface device for the bond0. Make sure the file is edited with the same content as the following

Note: The first parameter is to load the virtual network card driver module, the second parameter option means: miimon=100 every 100 seconds to check the link state, mode=0 This is the network card operating mode,0 for multi-nic load, 1 for multi-network card master standby

The Miimon is used for link monitoring. For example: miimon=100, then the system every 100MS monitoring link connection status, if one line is not connected to another line; Mode value indicates the mode of operation, he has 0,1,2,3 four modes, commonly used for 0, 12 kinds.
The mode=0 indicates that load balancing (round-robin) is balanced , and both NICs work.
Mode=1 indicates that fault-tolerance (active-backup) provides redundancy , working in a way that the primary and standby 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 the switch external link is down, and the switch itself is not faulted, then bonding will assume that the link is not a problem and continue to use

4. Edit/etc/rc.d/rc.local, make sure the modified file shows the same content as the following

Here the configuration has been completed, restart the computer, and then use Ifconfig to view the network card information, you will see a more than a name called Bond0 network card.

Below we discuss the following mode for 0, 1 o'clock, respectively.

Mode=1 operation in the main standby mode, then eth1 as the Backup network card is no ARP

That is to say in the main standby mode, when a network interface failure (such as the main switch power off, etc.), do not return to the network interruption, the system will be in accordance with the order of the specified network card cat/etc/rc.d/rc.local, the machine can still serve the external services, played a function of failure protection.

In the Mode=0 load balancing operation mode, he can provide twice times the bandwidth, let's look at the configuration information of the NIC, observe the Rx bytes and TX bytes value

In this case, a NIC fails, only the server egress bandwidth drops, and does not affect network use.

View bond0 Status:

Cat/proc/net/bonding/bond0

Note: It is important to note that every time you modify BOND0 mode, you need to restart your computer for the changes to take effect .

The network Cabondine technology under Linux not only increases the reliability of the server, but also increases the available network bandwidth, and provides the users with uninterrupted key service.

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.