Bonding Network Interfaces on LINUX5
The Linux bonding driver provides a method for aggregating multiple network interfaces into a single logical bonded interface.
The behavior of the bonded interfaces depends upon the mode; generally speaking, modes provide either hot standby or load balancing services.Additionally, link integrity
monitoring may be performed.
Verify and Ensure the Linux “bonding” module is loaded:
[root@matrix ~]# lsmod | grep bonding
bonding 142441 0
ipv6 435105 2 bonding,cnic
Insert the module if it is not loaded by issuing:
modprobe bonding
OS version
[root@matrix ~]# lsb_release -a
LSB Version: :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 5.6 (Final)
Release: 5.6
Codename: Final
check network device name,there are usually eth0,eth1.
[root@matrix devices]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:18:8B:78:27:3D
inet addr:192.168.168.230 Bcast:192.168.168.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:73 errors:0 dropped:0 overruns:0 frame:0
TX packets:47 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:7309 (7.1 KiB) TX bytes:7907 (7.7 KiB)
Interrupt:169 Memory:f8000000-f8012800
eth1 Link encap:Ethernet HWaddr 00:18:8B:78:27:3F
inet addr:192.168.168.195 Bcast:192.168.168.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:14 errors:0 dropped:0 overruns:0 frame:0
TX packets:17 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:968 (968.0 b) TX bytes:2853 (2.7 KiB)
Interrupt:169 Memory:f4000000-f4012800
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:90853 errors:0 dropped:0 overruns:0 frame:0
TX packets:90853 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:4560761 (4.3 MiB) TX bytes:4560761 (4.3 MiB)
bonding Configuration
[root@matrix network-scripts]# pwd
/etc/sysconfig/network-scripts
[root@matrix network-scripts]# cp ifcfg-eth0 ifcfg-bond0
[root@matrix network-scripts]# vi ifcfg-bond0
[root@matrix network-scripts]# cat ifcfg-bond0
# Broadcom Corporation NetXtreme II BCM5708 Gigabit Ethernet
DEVICE=bond0
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.168.230
NETMASK=255.255.255.0
NETWORK=192.168.168.0
GATEWAY=192.168.168.40
TYPE=Ethernet
[root@matrix network-scripts]# vi ifcfg-eth0
SLAVE=yes
# Broadcom Corporation NetXtreme II BCM5708 Gigabit Ethernet
DEVICE=eth0
BOOTPROTO=none
#HWADDR=00:18:8b:78:27:3d
ONBOOT=yes
MASTER=bond0
SLAVE=yes
#IPADDR=192.168.168.230
#NETMASK=255.255.255.0
#GATEWAY=192.168.168.40
#TYPE=Ethernet
[root@matrix network-scripts]# vi ifcfg-eth1
# Broadcom Corporation NetXtreme II BCM5708 Gigabit Ethernet
DEVICE=eth1
BOOTPROTO=none
#HWADDR=00:18:8b:78:27:3f
ONBOOT=yes
#HOTPLUG=no
#TYPE=Ethernet
#NETMASK=255.255.255.0
#IPADDR=192.168.168.195
#GATEWAY=192.168.168.40
MASTER=bond0
SLAVE=yes
[root@matrix network-scripts]# vi /etc/modprobe.conf
alias eth0 bnx2
alias eth1 bnx2
alias scsi_hostadapter megaraid_sas
alias scsi_hostadapter1 ata_piix
alias net-pf-10 off
alias ipv6 off
options ipv6 disable=1
alias bond0 bonding
options bond0 miimon=100 mode=1 primary=eth0
# mode=1 active-backup
# mode=0 balance-Round-robin
######################## Following is comment ##############################
miimon
Specifies the MII link monitoring frequency in milliseconds. This determines how often the link state of each slave is inspected for link failures. A value of zero disables
MII link monitoring. A value of 100 is a good starting point.
The use_carrier option, below, affects how the link state is determined. See the High Availability section for additional information. The default value is 0.
mode
Specifies one of the bonding policies. The default is balance-rr (round robin).
Possible values are:
balance-rr or 0
Round-robin policy: Transmit packets in sequential order from the first available slave through the last. This mode provides load balancing and fault tolerance.
active-backup or 1
Active-backup policy: Only one slave in the bond is active. A different slave becomes active if, and only if, the active slave fails. The bond’s MAC address is
externally visible on only one port (network adapter) to avoid confusing the switch.
############################ end ###############################################
[root@matrix network-scripts]# /etc/init.d/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: [ OK ]
–verify
[root@matrix network-scripts]# ifconfig
bond0 Link encap:Ethernet HWaddr 00:18:8B:78:27:3D
inet addr:192.168.168.230 Bcast:192.168.168.255 Mask:255.255.255.0
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:27 errors:0 dropped:0 overruns:0 frame:0
TX packets:32 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2352 (2.2 KiB) TX bytes:5950 (5.8 KiB)
eth0 Link encap:Ethernet HWaddr 00:18:8B:78:27:3D
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:14 errors:0 dropped:0 overruns:0 frame:0
TX packets:32 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1323 (1.2 KiB) TX bytes:5950 (5.8 KiB)
Interrupt:169 Memory:f8000000-f8012800
eth1 Link encap:Ethernet HWaddr 00:18:8B:78:27:3D
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:13 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1029 (1.0 KiB) TX bytes:0 (0.0 b)
Interrupt:169 Memory:f4000000-f4012800
–test
[root@matrix network-scripts]# ifdown eth0
[root@matrix network-scripts]# ifup eth0
[root@matrix network-scripts]# ifdown eth1
[root@matrix network-scripts]# ifup eth1
对不起,这篇文章暂时关闭评论。