1. ) #vi /etc/modprobe.conf
后添加
alias bond0 bonding
options bonding max_bonds=1
2. ) # vi ifcfg-bond0
加入如下内容
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=bond0
BOOTPROTO=none
BROADCAST=192.168.100.255
IPADDR=192.168.100.12
NETMASK=255.255.255.0
NETWORK=192.168.100.0
ONBOOT=yes
BONDING_OPTS="mode=1 miimon=100 primary=eth0"
3.) 修改ifcfg-eth0 ifcfg-eth1
# vi ifcfg-eth0
修改为如下内容
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
# cp ifcfg-eth0 ifcfg-eth1
# vi ifcfg-eth1
修改为如下内容
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
4. )重启服务
# service network restart
查看一下
[root@localhost ~]# ifconfig -a
bond0 Link encap:Ethernet HWaddr 00:0C:29:27:C3:F3
inet addr:192.168.100.141 Bcast:192.168.100.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe27:c3f3/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:9024 errors:0 dropped:0 overruns:0 frame:0
TX packets:1518 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:929203 (907.4 KiB) TX bytes:249989 (244.1 KiB)
eth0 Link encap:Ethernet HWaddr 00:0C:29:27:C3:F3
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:3572 errors:0 dropped:0 overruns:0 frame:0
TX packets:1429 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:376305 (367.4 KiB) TX bytes:240448 (234.8 KiB)
eth1 Link encap:Ethernet HWaddr 00:0C:29:27:C3:F3
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:5457 errors:0 dropped:0 overruns:0 frame:0
TX packets:102 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:553198 (540.2 KiB) TX bytes:11527 (11.2 KiB)
或者
1. 新建ifcfg-bond0
[root@dex network-scripts]# cd /etc/sysconfig/network-scripts/
[root@dex network-scripts]# cp ifcfg-eth0 ifcfg-bond0
[root@dex network-scripts]# vi ifcfg-bond0
加入如下内容
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=bond0
BOOTPROTO=none
BROADCAST=192.168.100.255
IPADDR=192.168.100.12
NETMASK=255.255.255.0
NETWORK=192.168.100.0
ONBOOT=yes
2. 修改ifcfg-eth0 ifcfg-eth1
[root@dex network-scripts]# vi ifcfg-eth0
修改为如下内容
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
[root@dex network-scripts]# cp ifcfg-eth0 ifcfg-eth1
[root@dex network-scripts]# vi ifcfg-eth1
修改为如下内容
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
3. 修改/etc/modprobe.conf文件
[root@dex network-scripts]# vi /etc/modprobe.conf
加入如下两行
alias bond0 bonding
options bond0 miimon=100 mode=1
mode=0 表示两块网卡同时工作,提供负载均衡
mode=1 表示提供冗余功能(主备模式)