注:bonding modes简介
数字表示 文字表示 说明
0 balance-rr 负载平衡模式
具容错功能, 其中一张 Slave 网卡失效仍可持续运作
1 active-backup 同一时间只有单一 Slave 网卡激活
Active Slave 网卡失效时自动启用次一顺位 Slave 网卡
2 balance-xor *未研究*
3 broadcast 所有 Slave 网卡一齐收发网路数据包
具容错功能, 其中一张 Slave 网卡失效仍可持续运作
4 802.3ad *未研究*
5 balance-tlb 传出自动负载平衡
传入由 Current Active Slave 负责
具容错功能, 其中一张 Slave 网卡失效仍可持续运作
6 balance-alb 传出及传入皆自动负载平衡
具容错功能, 其中一张 Slave 网卡失效仍可持续运作
[root@station18 ~]# uname -a
Linux station18.example.com 2.6.18-53.el5 #1 SMP Wed Oct 10 16:34:02
EDT 2007 i686 i686 i386 GNU/Linux
[root@station18 ~]# more /etc/sysconfig/network-scripts/ifcfg-eth0
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=dhcp
MASTER=bond0
SLAVE=yes
USERCTL=yes
#HWADDR=00:0c:29:77:fb:f5
[root@station18 ~]# more /etc/sysconfig/network-scripts/ifcfg-eth1
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=dhcp
#HWADDR=00:0c:29:77:fb:ff
MASTER=bond0
SLAVE=yes
USERCTL=yes
[root@station18 ~]# more /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
BOOTPROTO=none
ONBOOT=yes
NETWORK=192.168.1.0
NETMASK=255.255.255.0
IPADDR=192.168.1.110
USERCTL=no
GATEWAY=192.168.1.1
TYPE=Ethernet
[root@station18 ~]# more /etc/modprobe.conf
alias scsi_hostadapter mptbase
alias scsi_hostadapter1 mptspi
alias scsi_hostadapter2 ata_piix
alias snd-card-0 snd-ens1371
options snd-card-0 index=0
options snd-ens1371 index=0
remove snd-ens1371 { /usr/sbin/alsactl store 0 >/dev/null 2>&1 || : ;
}; /sbin/m
odprobe -r --ignore-remove snd-ens1371
alias eth0 pcnet32
alias eth1 pcnet32
##添加下面两行
alias bond0 bonding
options bonding miimon=100 mode=1
##重启network服务:
[root@station18 ~]# service network restart
##查看IP地址:
[root@station18 ~]# ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast master bond0 qlen 1000
link/ether 00:0c:29:77:fb:f5 brd ff:ff:ff:ff:ff:ff
inet6 fe80::20c:29ff:fe77:fbf5/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast master bond0 qlen 1000
link/ether 00:0c:29:77:fb:f5 brd ff:ff:ff:ff:ff:ff
inet6 fe80::20c:29ff:fe77:fbf5/64 scope link
valid_lft forever preferred_lft forever
4: sit0: <NOARP> mtu 1480 qdisc noop
link/sit 0.0.0.0 brd 0.0.0.0
5: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc
noqueue
link/ether 00:0c:29:77:fb:f5 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.110/24 brd 192.168.1.255 scope global bond0
inet6 fe80::20c:29ff:fe77:fbf5/64 scope link tentative
valid_lft forever preferred_lft forever
[root@station18 ~]# ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast master bond0 qlen 1000
link/ether 00:0c:29:77:fb:f5 brd ff:ff:ff:ff:ff:ff
inet6 fe80::20c:29ff:fe77:fbf5/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast master bond0 qlen 1000
link/ether 00:0c:29:77:fb:f5 brd ff:ff:ff:ff:ff:ff
inet6 fe80::20c:29ff:fe77:fbf5/64 scope link
valid_lft forever preferred_lft forever
4: sit0: <NOARP> mtu 1480 qdisc noop
link/sit 0.0.0.0 brd 0.0.0.0
5: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc
noqueue
link/ether 00:0c:29:77:fb:f5 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.110/24 brd 192.168.1.255 scope global bond0
inet6 fe80::20c:29ff:fe77:fbf5/64 scope link tentative
valid_lft forever preferred_lft forever
另外一种配置方式:
[root@station18 ~]# more /etc/sysconfig/network-scripts/ifcfg-bond0 |
grep -v "#"
DEVICE=bond0
BOOTPROTO=static
ONBOOT=yes
BROADCAST=192.168.1.255
NETWORK=192.168.1.0
NETMASK=255.255.255.0
IPADDR=192.168.1.110
USERCTL=yes
GATEWAY=192.168.1.1
TYPE=Ethernet
[root@station18 ~]# more /etc/sysconfig/network-scripts/ifcfg-eth0 |
grep -v "#"
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
[root@station18 ~]# more /etc/sysconfig/network-scripts/ifcfg-eth1 |
grep -v "#"
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
4./etc/rc.d/rc.local中添加如下一行:
ifenslave bond0 eth0 eth1 //
[root@station18 ~]# tail -n 2 /etc/modprobe.conf
alias bond0 bonding
options bond0 miimon=100 mode=1 // 关于miimon和mode可以参考
http://www.redhat.com/docs/manuals/enterprise/RHEL-3-Manual/ref-
guide/s1-modules-ethernet.html#S2-MODULES-BONDING
[root@station18 ~]# ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast master bond0 qlen 1000
link/ether 00:0c:29:77:fb:f5 brd ff:ff:ff:ff:ff:ff
inet6 fe80::20c:29ff:fe77:fbf5/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast master bond0 qlen 1000
link/ether 00:0c:29:77:fb:f5 brd ff:ff:ff:ff:ff:ff
inet6 fe80::20c:29ff:fe77:fbf5/64 scope link
valid_lft forever preferred_lft forever
4: sit0: <NOARP> mtu 1480 qdisc noop
link/sit 0.0.0.0 brd 0.0.0.0
5: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc
noqueue
link/ether 00:0c:29:77:fb:f5 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.110/24 brd 192.168.1.255 scope global bond0
inet6 fe80::20c:29ff:fe77:fbf5/64 scope link
valid_lft forever preferred_lft forever
或者下面三条命令:
[root@station18 ~]# modprobe bonding
[root@station18 ~]# ifconfig bond0 192.168.0.1 netmask 255.255.0.0
[root@station18 ~]# ifenslave bond0 eth0 eth1
##更加详细的可以安装kernel-doc-.....rpm
[root@station18 ~]# more /usr/share/doc/kernel-doc-2.6.18/Documentation/networking/bonding.txt