One, what is bonding
More than one card tied together, as a network card, to achieve load balancing and improve bandwidth, Linux dual network adapter binding an IP address, the real work is to use two network card virtual for a piece, using the same IP address, we can get better faster service.
Second, the configuration process
The configuration is simple, altogether four steps:
The experimental operating system is Redhat Linux Enterprise 3.0
Binding Prerequisites: The chipset model is the same, and the NIC should have its own stand-alone BIOS chip.
1. Edit virtual network Interface configuration file, specify network card IP
The code is as follows:
Vi/etc/sysconfig/network-scripts/ifcfg-bond0
< p>[root@rhas-13 root]# Cp/etc/sysconfig/network-scripts/ifcfg-eth0 ifcfg-bond0
2 #vi ifcfg-bond0
Change the first line into device=bond0
The code is as follows:
# Cat Ifcfg-bond0
< p>device=bond0
< p>bootproto=static
< p>ipaddr=172.31.0.13
< p>netmask=255.255.252.0
< p>broadcast=172.31.3.254
< P>onboot=yes
< p>type=ethernet
Here's the idea, do not specify the IP address, subnet mask, or network card ID of a single network card. Specify the above information in the virtual adapter (bonding).
The code is as follows:
[Root@rhas-13 network-scripts]# Cat Ifcfg-eth0
< P>device=eth0
< P>onboot=yes
< P>BOOTPROTO=DHCP
< p>[root@rhas-13 network-scripts]# Cat Ifcfg-eth1
< P>device=eth0
< P>onboot=yes
< P>BOOTPROTO=DHCP
3 # vi/etc/modules.conf
Edit the/etc/modules.conf file and add the following line to enable the system to load the bonding module at startup and the external virtual network interface device as Bond0
Add the following two lines
The code is as follows:
Alias Bond0 Bonding
< p>options bond0 miimon=100 mode=1
Note: Miimon is used for link monitoring. For example: miimon=100, then the system every 100MS monitoring link connection state, if there is a line does not pass on to another line; Mode's value represents the working mode, he has 0,1,2,3 four modes, commonly used for 0, 12 kinds.
Mode=0 indicates that the load balancing (round-robin) is loaded in a balanced way and both cards work.
Mode=1 means that fault-tolerance (active-backup) provides redundancy, working in a way that is normally done, which means that by default only one network card works and the other is backed up.
Bonding can only provide link monitoring, that is, whether the link from the host to the switch is connected. If only the switch is down on the external link, and the switch itself is not faulty, then bonding will think that the link is no problem and continue to use
4 # Vi/etc/rc.d/rc.local
Join two lines
The code is as follows:
Ifenslave bond0 eth0 eth1
< P>route add-net 172.31.3.254 netmask 255.255.255.0 bond0
By this time the machine has been configured to reboot.
The reboot will see the following information to indicate that the configuration was successful
................
Bringing Up interface Bond0 OK
Bringing Up interface eth0 OK
Bringing Up interface eth1 OK
Bonding mode of work
The Linux bonding uses the rotation policy by default.
The basic category is the main standby mode and load Balancing mode:
BALANCE-RR (mode=0)
Rotation (round-robin) Policy: Send packets from top to bottom in every slave interface. This model provides load balancing and fault-tolerant capabilities.
Active-backup (mode=1)
Active-Backup (primary) policy: in bindings, only one slave is activated. Other slave are activated when and only if the active slave interface fails. To avoid confusion in the switch, the MAC address that is bound is visible only on one external port. In 2.6.2 and later versions of Bongding, when a failover occurs in primary standby mode, bonding will send one or more gratuitous on the newly activated slave Arp.bonding the main salve interface and all VLAN interfaces configured on the interface will send gratuitous ARP, provided that at least one IP address is configured on those interfaces. The gratuitous ARP sent on the VLAN interface will be accompanied by the appropriate VLAN ID. This mode provides fault tolerance, primary option,documented below can affect the behavior of this mode.
Balance-xor (mode=2)
XOR policy: Based on the selected routing hash policy.
This model provides load balancing and fault-tolerant capabilities.
Broadcast (MODE=3)
Broadcast policy: All messages are transmitted on all slave interfaces. This mode provides fault tolerant capabilities.
802.3AD (mode=4)
IEEE 802.3ad dynamic Link aggregation. Create an aggregation group that shares the same rate and duplex mode. can use all the slave to establish the aggregation link according to the 802.3AD specification. The outbound selection of salve depends on the hash policy of the transport, the default policy is a simple XOR policy, and the hash policy can be changed through the Xmit_hash_policy option. It should be noted that not all transport strategies are compatible with 802.3AD, especially in the 43.2.4 section of the 802.3AD standard about packet mis-ordering requirements. The realization of different individuals often appears to be very large incompatible.
Prerequisite:
1. The basic drive for each slave supports Ehtool acquisition rate and duplex status.
2. The switch supports IEEE 802.3AD dynamic Link aggregation. Most switches need to use some configuration to enable 802.3ad mode.
Balance-tlb (mode=5)
Adaptive Transport load balancing: Channel bindings do not require special switch support. The distribution of export traffic depends on the current load per slave (calculating relative speed). Import flow from the current slave receive. If a salve error is received, the other slave takes over the MAC address of the failed slave and continues to receive.
Prerequisite:
The basic driver for each slave supports Ehtool acquisition rate status.
Balance-alb (mode=6)
Adaptive load Balancing: Includes balance-tlb (mode 5) and receive load balancing for IPV4 traffic, and does not require special switch support. Receive load balancing is implemented through ARP negotiation. The bonding driver intercepts the ARP replies (ARP response message) and uses a slave hardware address of bond to overwrite the source address of the ARP message, which makes the server use different hardware addresses for different devices. The incoming traffic of the connection established by this server is also load balanced. When this machine sends ARP request, the bonding driver replicates and saves the IP information of the node through the ARP message. When an ARP reply,bonding is received from another node to obtain the hardware address of the node and will respond to an ARP Reply that contains the hardware address of the binding slave to send the node. The problem with the load balance of ARP negotiation is that each time the ARP message is broadcast with the hardware address of the bond, all the data sent by the other nodes is concentrated on a slave, and when processing the ARP update to all the other nodes, each node will learn the hardware address again, causing the traffic reallocation. When a new slave is added or an inactive slave is reactivated, it can also cause the receive traffic to redistribute. The receiving traffic load is a serial (rotation) distribution on the slave of the highest set of bond rates.
When a link is attached or a new slave joins, Bond will reinitialize the ARP replies to all clients. The value of the Updelay parameter must be equal to or greater than the forwarding delay of the switch, lest the ARP replies be blocked by the switch.
Prerequisite:
1. The basic drive for each slave supports Ehtool acquisition rate status.
2. Basic driver Support Reset the hardware address when the device is open. Each slave is also required to have a unique hardware address. If Curr_active_slave fails, its hardware address is replaced with the newly selected Curr_active_slave hardware address