介绍:
系统版本:
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
网卡eth0初始配置:
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
BOOTPROTO=static
NAME=eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.14.211
PREFIX=24
GATEWAY=192.168.14.254
DNS1=10.1.2.30
DNS2=114.114.114.114
网卡eth1初始配置:
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth1
TYPE=Ethernet
BOOTPROTO=static
NAME=eth1
DEVICE=eth1
ONBOOT=yes
IPADDR=192.168.14.215
PREFIX=24
GATEWAY=192.168.14.254
DNS1=10.1.2.30
DNS2=114.114.114.114
一、配置双网卡主备
1、关闭 NetworkManager服务
[root@localhost ~]# systemctl stop NetworkManager
[root@localhost ~]# systemctl disable NetworkManager
2、添加bond0
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-bond0
TYPE=Bond
DEVICE=bond0
IPADDR=192.168.14.220
PREFIX=24
BONDING_OPTS=mode=active-backup
NAME=bond0
ONBOOT=yes
3、修改eth0
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
BOOTPROTO=static
NAME=eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.14.211
PREFIX=24
GATEWAY=192.168.14.254
DNS1=10.1.2.30
DNS2=114.114.114.114
MASTER=bond0 #新增
SLAVE=yes #新增
4、修改eth1
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth1
TYPE=Ethernet
BOOTPROTO=static
NAME=eth1
DEVICE=eth1
ONBOOT=yes
IPADDR=192.168.14.215
PREFIX=24
GATEWAY=192.168.14.254
DNS1=10.1.2.30
DNS2=114.114.114.114
MASTER=bond0 #新增
SLAVE=yes #新增
5、重启网卡
[root@localhost ~]# systemctl restart network
6、查看状态
[root@localhost ~]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth0
MII Status: up
MII Polling Interval (ms): 0
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:08:01:5d
Slave queue ID: 0
Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:08:01:67
Slave queue ID: 0
7、添加临时默认路由(永久路由自行添加配置文件)
[root@localhost ~]# route add -net 0.0.0.0/0 gw 192.168.14.254 dev bond0
二、模拟生产环境网卡故障
1、关闭eth0主网卡模拟故障,eth1从备转为主
[root@localhost ~]# ifdown eth0
2、故障网卡eth0恢复之后并不会抢占eth1,从而避免网络波动
[root@localhost ~]# ifup eth0
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/95221.html