Linux multi-NIC load balancing main standby Bonding technology Practice Course __linux

Source: Internet
Author: User
Tags switches hp server cisco switch

Linux system to do bonding network card binding, this test is the use of the environment CentOS 6.3 + virtual machine + Dual network card, installed in the virtual network card, will not be the product ifcfg-eth1 files, need to manually copy ifcfg-eth1, if necessary to the MAC address, Use Ifconfig to write the corresponding MAC address to the config file.
1. Root user login, using Ifconfig to see whether the network card is normal.
Linux By default is DHCP to obtain IP, when the network does not have DHCP, will request timeout, and caused the network card can not start, but the network card does not start, as long as the confirmation lsmod in the network card driver module has been normal loading on it, and then we need to modify the network card configuration file.

2. New virtual binding NIC Bond0

Execute cd/etc/sysconfig/network-scripts into the NIC configuration file directory

This directory will have the network card configuration file

Ifcfg-eth0 corresponds to Eth0

Ifcfg-eth1 corresponds to Eth1

Copy Ifcfg-eth0 for Ifcfg-bond0

3. Edit Network card configuration file

Edit Ifcfg-bond0 File

#vi ifcfg-bond0

The original configuration file is as follows

After modification, you need to add a static IP address (NIC bindings do not recommend using dynamic IP), subnet masks, and gateways are as follows

(Note: In addition to BOND0 set IP and other information outside the real card can not set IP address)

Edit Ifcfg-eth0 File
#vi Ifcfg-eth0
The original configuration file is as follows

After modification

Three network adapters are prepared.

This environment uses CentOS6.3 without/etc/modprobe.conf this file

Edit/etc/modprobe.d/dist.conf

Add the following 2 lines to the bottom of the file

Alias Bond0 Bonding

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.

5. Modify/etc/rc.local configuration file

Add the following 2 lines

Ifenslave bond0 eth0 eth1//If the above added Master,slave can not add the bank

Route add-net 10.0.1.0 netmask 255.255.255.0 bond0//This line can not be added

-net is followed by a network segment netmask followed by a subnet mask

6. Reboot the server to see if the BOND0 has been started at post, and if it starts, it will prove successful.

You can also use Lsmod |more to see if the bonding module has been successfully loaded

7. Test Configuration Results
/proc/net/bonding/bond0 file, this file is a memory image file, is a temporary, timely file, the system state changes will be directly passed to the file

Ping 10.0.1.92 The action of the test, and then disconnect the network cable to see if the ping will lose the packet

View the Cat/proc/net/bonding/bond0 file at the same time, look at the current active network card (currently active slave:eth1) and network card status (MII Status:down) to determine whether the normal switch

Test the effect in the virtual machine.
Ping the IP (10.0.1.92) address we just set up from another machine, and then under Virtual machine VMware, click one of the NIC

Select Disconnect (disconnect)

You can see that the ping is back to normal after only one time out (the real environment may take a few seconds). It means our configuration is working.

Note: Bonding can only provide link monitoring, that is, whether the link from the host to the switch is connected. If only the switch to the external link down, and the switch itself does not fail, then bonding will think that the link is not a problem and continue to use, two network adapters to a switch, the switch port needs to do aggregation.

Another reference:

Network card binding technology has been out for a long time, in different platforms under different names, under the Linux called BONDING,IBM called Etherchanel,broadcom team, but how the name changed, the effect is to two or more cards as a network card use, While increasing the bandwidth, it can also improve redundancy, seven modes, more commonly used is to improve redundancy, respectively, and different switches connected to improve reliability, but sometimes the server bandwidth is not enough can also increase the bandwidth, where Cisco switches and HP server connected, Cisco switches to do port convergence, server to do network card binding , CONFIGURED as follows:
Server is CentOS6.2
Cat/etc/sysconfig/network-scripts/ifcfg-bond0
Device=bond0
Bootproto=static
Type=ethernet
Onboot=yes
ipaddr=192.168.0.32
netmask=255.255.192.0
gateway=10.10.0.1
Cat/etc/sysconfig/network-scripts/ifcfg-eth0
Device=eth0
Bootproto=static
Type=ethernet
Onboot=yes
Master=bond0
Slave=yes
Userctl=no
Cat/etc/sysconfig/network-scripts/ifcfg-eth1
Device=eth0
Bootproto=static
Type=ethernet
Onboot=yes
Master=bond0
Slave=yes
Userctl=no
Vim/etc/modprobe.d/dist.conf
Alias Bond0 Bonding
Options bond0 miimon=100 mode=0 (0, which represents balanced load dual NIC work, RR algorithm, mode=1, automatic main preparation, one piece of work)
Cisco switch corresponding port configuration port aggregation:
R1#configure Terminal
R1 (config) #int range G0/1-2
R1 (Config-int-range) #channel-group 1 mode on
Connecting the switch g0/1-2 to the corresponding port on the server, the bandwidth is significantly increased after testing

Another important reference material:

Linux dual NIC Bonding

is divided into three steps:

1, create BOND0 network card:

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

Add the following:

Device=bond0
bootproto=none
onboot=yes
network=192.168.0.0
netmask=255.255.255.0
IPADDR= 192.168.0.10
userctl=no
gateway=192.168.0.254
type=ethernet

2, modify eth0, eth1:

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

Device=eth0
bootproto=none
onboot=yes
master=bond0
slave=yes
userctl=yes

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

Device=eth1
bootproto=none
onboot=yes
master=bond0
slave=yes
userctl=yes

3, modify the modprobe.conf:

for kernel recognition. Add the setting parameter, the Miimon value indicates the time that the two network cards monitor each other, in the unit of Ms. The mode value is working mode, can be set to high availability or load balancing, 0 is highly available (default), 1 is load balanced, and another XOR mode.

Vim/etc/modprobe.conf

Alias bond0 bonding
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 assume that the link is not problematic and continue to use it.

4, adjust the switch, bind multiple ports, do link aggregation

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's ARP table, the MAC address of the corresponding port has more than one, then the switch received to the MAC address of the packet should be forwarded to which port. Under normal circumstances, the MAC address is the only global, a MAC address corresponding to multiple ports must make the switch confused.


So mode0 bond. If you are connected to a switch, these ports should be aggregated (Cisco is called Ethernetchannel,foundry called PortGroup), because after the switch is aggregated, Several ports under aggregation are also bundled into a MAC address.

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.