Linux system Bonding

Source: Internet
Author: User

Transferred from: http://yanghuawu.blog.51cto.com/2638960/1160819

================================================

Dual network card binding order IP address in order to provide high availability of the network, we may need to bind multiple network cards into a single virtual network card to provide services, so that even if one of the physical network card fails, it will not cause a connection interruption. Multiple NIC bindings.

In order to provide high availability of the network, we may need to bind multiple network cards into a virtual network card to provide services, so that even if one of the physical NIC fails, it will not cause a connection interruption. In Linux called BONDING,IBM called etherchanel,broadcom called Team, but the name of how to change, the effect is to use two or more network card as a network card, in addition to increase the bandwidth can also improve redundancy. For example, we can bind eth0 and eth1 to a virtual NIC bond0 under CentOS 6.3.

Experiment Configuration:

Mode=1: Indicates that fault-tolerance (active-backup) provides redundancy, working in a way that the primary and standby work, where a network card is working (if the eth0 is broken), then automatically switch to another block network card (eth1 do Backup).

System

Device Name

IP Address

Subnet mask

CentOS 6.3_64bit

Eth0

Eth1

Bond0

10.1.3.210

255.255.255.0

1. Check the Host network card

[Email protected] ~]# cd/etc/sysconfig/network-scripts/

[email protected] network-scripts]# LL

Total 200

-rw-r--r--. 1 root root 212 Mar 22:15 Ifcfg-eth0

-rw-r--r--1 root root 212 Mar 19:10 ifcfg-eth1

2. Copy ifcfg-bond0

[email protected] network-scripts]# CP Ifcfg-eth0 IFCFG-BOND0

[email protected] network-scripts]# LL

Total 204

-rw-r--r--1 root root 212 Mar 19:12 ifcfg-bond0

-rw-r--r--. 1 root root 212 Mar 22:15 Ifcfg-eth0

-rw-r--r--1 root root 212 Mar 19:10 ifcfg-eth1

3. Edit Ifcfg-bond0, Ifcfg-eth0, ifcfg-eth1

[Email protected] network-scripts]# vim ifcfg-bond0

Device=bond0

Bootproto=static

ipaddr=10.1.3.210

netmask=255.255.255.0

gateway=10.1.3.254

Onboot=yes

Userctl=no

[Email protected] network-scripts]# vim Ifcfg-eth0

Device=eth0

Onboot=yes

Bootproto=none

Master=bond0

Slave=yes

Userctl=no

[Email protected] network-scripts]# vim ifcfg-eth1

Device=eth1

Onboot=yes

Bootproto=none

Master=bond0

Slave=yes

Userctl=no

4. Module loading

[Email protected] ~]# vim/etc/modprobe.d/dist.conf

At the end, add the following:

#加载bonding模块, external virtual network interface device is BOND0

Alias Bond0 Bonding

Options Bond0 miimon=100 mode=1

[[email protected] ~]# grep bond0/etc/modprobe.d/dist.conf

Alias Bond0 Bonding

Options Bond0 miimon=100 mode=1

Description

The Miimon is used for link monitoring. For example: miimon=100, the Unit is MS (MS) this side of 100, is 100ms, that is, 0.1 seconds then the system every 100MS monitoring link connection status, if there is a line does not pass to another line; Mode value indicates the mode of operation, he has 0,1,2,3 four modes, Commonly used is 0, 12 kinds.

There are seven types of mode (0~6), which explains two commonly used options.

Mode=0: Indicates that load balancing (round-robin) is a balanced mode and both NICs are working.

Mode=1: Indicates that fault-tolerance (active-backup) provides redundancy, working in a way that the primary and standby work, where a network card is working (if the eth0 is broken), then automatically switch to another block network card (eth1 do Backup).

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.

5. Restart the network service to make the configuration effective

[Email protected] ~]# service network restart

Shutting down interface eth0: [OK]

Shutting down interface eth1: [OK]

Shutting down loopback interface: [OK]

Bringing up loopback interface: [OK]

Bringing up interface Bond0:rtnetlink Answers:file exists

Error adding address 10.1.3.210 for bond0.

Rtnetlink answers:file exists [OK]

6. View Bond0 Interface Status

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

Ethernet Channel Bonding driver:v3.6.0 (September 26, 2009)

Bonding mode:fault-tolerance (Active-backup)

Primary Slave:none

Currently Active Slave:eth0//eth0 main mode

MII Status:up

MII Polling Interval (ms): 100

Up Delay (ms): 0

Down Delay (ms): 0

Slave Interface:eth0

MII Status:up

speed:1000 Mbps

Duplex:full

Link Failure count:0

Permanent HW addr:00:0c:29:c9:6d:18

Slave Queue id:0

Slave interface:eth1

MII Status:up

speed:1000 Mbps

Duplex:full

Link Failure count:0

Permanent HW addr:00:0c:29:c9:6d:22

Slave Queue id:0

7. Check the status of the middle table:

[Email protected] ~]# route-n

Kernel IP Routing Table

Destination Gateway genmask Flags Metric Ref use Iface

10.1.3.0 0.0.0.0 255.255.255.0 U 0 0 0 bond0

169.254.0.0 0.0.0.0 255.255.0.0 U 1004 0 0 bond0

0.0.0.0 10.1.3.254 0.0.0.0 UG 0 0 0 bond0

[Email protected] ~]# Lsmod | grep bond

Bonding 127060 0

8. Testing

Select a Windows 7 machine ping test machine, and then stop the currently used NIC Eth0 to see if you can continue pinging;

Test results:

Lost a package.

View Bond0 Interface Status

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

Ethernet Channel Bonding driver:v3.6.0 (September 26, 2009)

Bonding mode:fault-tolerance (Active-backup)

Primary Slave:none

Currently Active slave:eth1//eth1 main mode

MII Status:up

MII Polling Interval (ms): 100

Up Delay (ms): 0

Down Delay (ms): 0

Slave Interface:eth0

MII Status:down

Speed:unknown

Duplex:unknown

Link Failure count:1

Permanent HW addr:00:0c:29:c9:6d:18

Slave Queue id:0

Slave interface:eth1

MII Status:up

speed:1000 Mbps

Duplex:full

Link Failure count:1

Permanent HW addr:00:0c:29:c9:6d:22

Slave Queue id:0

Configuration Complete!

Linux system Bonding

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.