2、修改 /etc/sysconfig/network-scripts/ifcfg-eth0网卡属性
[root@support ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
HWADDR=00:30:48:56:DA:72
ONBOOT=yes
MASTER=bond0
SLAVE=yes
3、修改 /etc/sysconfig/network-scripts/ifcfg-eth1网卡属性
[root@support ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
BOOTPROTO=none
HWADDR=00:30:48:56:DA:73
ONBOOT=yes
HOTPLUG=no
DHCP_HOSTNAME=support
MASTER=bond0
SLAVE=yes
说明:修改单个网卡配置,主要是去掉IP 地址、子网掩码等信息。同时添加MASTER及SLAVE两项参数。
MASTER=<bond-interface>:<bond-interface> 的值是以太网卡连接到的通道绑定接口的名称,这个指令与 SLAVE 指令配合使用。
SLAVE=<yes|no>:yes - 表示此设备可以由 MASTER 指令中配置的通道绑定接口进行控制。 no - 表示此设备不能由 MASTER 指令中配置的通道绑定接口进行控制。
4、编辑 /etc/modules.conf 文件,添加:alias bond0 bonding,以使系统在启动时加载bonding模块,对外虚拟网络接口设备为 bond0
[root@support ~]# cat /etc/modprobe.conf
alias bond0 bonding
alias eth0 e1000
alias eth1 e1000
alias scsi_hostadapter ata_piix
alias scsi_hostadapter1 usb-storage
注:在linux6下测试时,发现没有modprobe.conf这个文件,需要进入modprobe.d文件夹创建bond0.conf,再将“alias bond0 bonding”添加到里面
[root@ara ~]# cat /etc/modprobe.d/bond0.conf
alias bond0 bonding
5、重启网络服务,以使用bond生效
[root@support ~]# service network restart
在网络设置可以看到bond0与eth0、eth1之间的主从关系
[root@support ~]# ifconfig
bond0 Link encap:Ethernet HWaddr 00:30:48:56:DA:72
inet addr:10.8.0.231 Bcast:10.8.255.255 Mask:255.255.0.0
inet6 addr: fe80::230:48ff:fe56:da72/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:19015 errors:0 dropped:0 overruns:0 frame:0
TX packets:4714 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2557139 (2.4 MiB) TX bytes:469585 (458.5 KiB)
eth0 Link encap:Ethernet HWaddr 00:30:48:56:DA:72
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:10592 errors:0 dropped:0 overruns:0 frame:0
TX packets:2011 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:1295667 (1.2 MiB) TX bytes:209014 (204.1 KiB)
eth1 Link encap:Ethernet HWaddr 00:30:48:56:DA:72
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:8423 errors:0 dropped:0 overruns:0 frame:0
TX packets:2705 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:1261472 (1.2 MiB) TX bytes:260887 (254.7 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1178 errors:0 dropped:0 overruns:0 frame:0
TX packets:1178 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2054820 (1.9 MiB) TX bytes:2054820 (1.9 MiB)
至此,完成了bonding配置,系统已经在网卡的负载均衡模式下运行,随意拔掉一个网卡口的网线,网线依然正常。