Centos 7 双网卡绑定,主备工作状态

介绍:

系统版本:
[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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

友人a笔记

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值