CentOS7双网卡绑定与解绑

笔者的版本是centos7.8

通过两种模式去做测试,在vmware vsphere 5.5中测试

1 通过命令行的模式去

一、常用的三种双网卡绑定模式(mode)

  • mode=0,网卡负载均衡模式。

  • mode=1,网卡容错模式。

  • mode=6,网卡虚拟化方式。

二、准备工作

1、查看网卡信息

[[email protected] ~]# ip addr

CentOS7双网卡绑定与解绑

2、拷贝网卡配置文件

[[email protected] ~]# cd /etc/sysconfig/network-scripts/

[[email protected] network-scripts]# cp ifcfg-ens33 ifcfg-ens37

[[email protected] network-scripts]# cp ifcfg-ens33 ifcfg-bond0

3、双网卡绑定

1)先停止NetworkManager

[[email protected] ~]# systemctl stop NetworkManager

[[email protected] ~]# systemctl disable NetworkManager

CentOS7双网卡绑定与解绑

2)手工写绑定的配置 ifcfg-bond0

  • 配置ifcfg-bond0

[[email protected] ~]# vi /etc/sysconfig/network-scripts/ifcfg-bond0

TYPE=”Ethernet”
BOOTPROTO=”none”

 

NAME=”bond0″

DEVICE=”bond0″

ONBOOT=”yes”

IPADDR=192.168.80.130

NETMASK=255.255.255.0

GATEWAY=192.168.80.2

USERCTL=”no”

  • 配置ifcfg-ens33

[[email protected] ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33

TYPE=”Ethernet”
BOOTPROTO=”none”

 

NAME=”ens33″

DEVICE=”ens33″

ONBOOT=”yes”

MASTER=”bond0″

slave=”yes”

  • 配置ifcfg-ens37

[[email protected] ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens37

TYPE=”Ethernet”
BOOTPROTO=”none”

 

NAME=”ens37″

DEVICE=”ens37″

ONBOOT=”yes”

MASTER=”bond0″

slave=”yes”

  • 配置网卡绑定

vi /etc/modprobe.d/bonding.conf

alias bond0 bonding
options bond0 miimon=100 mode=1

3)开机使网卡绑定生效

vi /etc/rc.d/rc.local

在后方插入:ifenslave bond0 ens33 ens37

4)重启服务生效

[[email protected] network-scripts]# systemctl restart network

[[email protected] network-scripts]# ifenslave bond0 ens33 ens37

5)状态检查

[[email protected] ~]# ifconfig -a

CentOS7双网卡绑定与解绑

[[email protected] ~]# cat /proc/net/bonding/bond0

CentOS7双网卡绑定与解绑

4、双网卡解绑(请按照顺序操作)

rm -rf /etc/sysconfig/network-scripts/ifcfg-bond0

rm -rf /etc/modprob.d/bonding.conf

rm -rf /etc/sysconfig/network-scripts/ifcfg-ens33

rm -rf /etc/sysconfig/network-scripts/ifcfg-ens37

rmmod bonding

systemctl restart network

本站文章都归www.zhangyujia.cn和www.laozhangteam.com所有,若转载请注明出处。
嘉叔的博客 » CentOS7双网卡绑定与解绑

 

 

第二种方式在图形化界面

1 首先输入 nm-connection-editor 

CentOS7双网卡绑定与解绑

2 点击+号添加绑定

CentOS7双网卡绑定与解绑

3 把网卡绑定进去,设置绑定模式,设置绑定的IP地址与网关等

CentOS7双网卡绑定与解绑

CentOS7双网卡绑定与解绑