CentOS 7 网卡bond - 简书
系统: CentOS 7.6
需求:
- 网卡1,2绑定做业务口
- 网卡3,4绑定做心跳口
实施:
进入 /etc/sysconfig/network-scripts/
目录,修改ifcfg-em1和ifcfg-em2网口配置文件
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=em1
UUID=e3814ece-5de5-4468-a7f5-9b27837dfff6
DEVICE=em1
ONBOOT=yes
IPV6_PRIVACY=no
MASTER=bond0
SLAVE=yes
其中NAME与DEVICE修改成对应的网卡,随后创建bond网卡文件 ifcfg-bond0
,内容如下:
DEVICE=bond0
TYPE=bond
ONBOOT=yes
BOOTPROTO=static
IPADDR=10.0.1.13
NETMASK=255.255.255.0
BONDING_OPTS="miimon=100 mode=4"
BONDING_MASTER=yes
MTU=1500
NM_CONTROLLED=no
心跳口bond如法炮制,完成后重启network服务 systemctl restart network
,发现无法正常重启,查看日志 cat /var/log/messages | grep network
,发现网卡无法启动,出错信息如下:
Error: Connection activation failed: Master device 'ifcfg-em1' can't be activated: Device unmanaged or not available for activation
Error: Connection activation failed: Master device 'ifcfg-em2' can't be activated: Device unmanaged or not available for activation
Error: Connection activation failed: Master device 'ifcfg-em3' can't be activated: Device unmanaged or not available for activation
Error: Connection activation failed: Master device 'ifcfg-em4' can't be activated: Device unmanaged or not available for activation
Baidu了一下,都是关于停用NetWorkManger和添加MAC地址的错误方法,重启依然无法启动网络服务,后问Google,查到用ifconfig中的命名方式修改配置文件名,随后修改ifcfg-em1,ifcfg-em2,ifcfg-em3,ifcfg-em4为em1,em2,em3,em4,顺利重启服务,但是依然无法ping通地址,继续研究交换机是否开启802.3ad协商,发现都配置正确,
查看bond状态 cat /proc/net/bonding/bond0
,发现一切正常,最后尝试 ifup em1&&ifup em2
顺利解决,如需删除bond,先删除ifcfg-bond0和ifcfg-bond1,然后还原em1,em2,em3,em4的默认配置,最后 rmmod bonding
,解除bond,重启network服务 systemctl restart network
,即可解除bond(如远程连接状态,请执行 rmmod bonding&&systemctl restart network
),恢复单网口模式。