解决一个网卡突然损坏,而导致不能工作的问题,添加多个网卡就可以避免
1. 配置bond网络接口
(1)Red Hat Enterprise Linux 允许管理员使用 bonding 内核模块和称为通道绑定接口的特殊网络接口将多个网络接口绑定 到一个通道。根据选择的绑定模式 , 通道绑定使两个或更多个网络接口作为一个网络接口 , 从而增加带宽和提供冗余性
监控命令 watch -n 1 cat /proc/net/bonding/bond0
<1>多添加一个网卡,共两个
<2>ifconfig #如果eth0设置了ip,则执行第三步,否则执行第五步
<3>nmcli connection delete 'System eth0' #自己的网络链接名叫什么就删什么,名字必须用引号引起来
<4> ifconfig #查看ip已经被删除
con-name bond0 #配置文件链接名
ifname bond0 #指定接口
type bond #bond类型
mode active-backup #选定bond工作模式
ip4 172.25.254.238/24 #设定ip以及网关
<6>nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0 #添加eth0设备到bond0
<7> nmcli connection add con-name eth1 ifname eth1 type bond-slave master bond0 #添加eth1设备到bond0
<8>ifconfig eth0 down #破坏eth0,如果一个网卡坏掉,另外一个网卡立刻顶替他的工作
实验效果:
2.team的种类
broadcast #广播容错
roundrobin # 平衡轮叫
activebackup # 主备
loadbalance #负载均衡
前提:删除bond0
<1> nmcli connection delete bond0
<2>nmcli connection delete eth0
<3>nmcli connection delete eth1
开始配置:
<1> nmcli connection add con-name team0 ifname team0 type team config '{"runner":{"name":"activebackup"}}' ip4 172.25.254.238/24
<2>ifconfig
team0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.25.254.138 netmask 255.255.255.0 broadcast 172.25.254.255
ether 26:f7:c2:0e:af:62 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
<3>nmcli connection add con-name eth0 ifname eth0 type team-slave master team0
<4> nmcli connection add con-name eth1 ifname eth1 type team-slave master team0
<5>ifconfig eth0 down #破坏eth0,如果一个网卡坏掉,另外一个网卡立刻顶替他的工作
破坏之前:
概述:网络桥接是用来连接不同的网段,使虚拟机的网卡直接连接到真机的真实网卡,使上网速度更快
前提:删除之前建立的team0
nmcli connection delete team0
nmcli connection delete eth0
nmcli connection delete eth1
方法1(以命令的形式,临时的,重启网络会失效):
开始设置:
<1> brctl show #查看网桥,没有网桥
<2> brctl addbr br0 #添加网桥br0
<3> brctl show #查看是否成功添加网桥
<4> ifconfig
<6>ifconfig br0 #查看ip是否设置成功
<7>ping 172.25.254.78 #此时ping不通
<8> brctl show #没有网络接口 ,所以ping不通
<9>brctl addif br0 eth0 # 添加eth0网络接口
<10>brctl show #查看添加成功
<11>ping 172.25.254.38 #此时可以ping通
还原环境:
<1>brctl delif br0 eth0 #删除网桥链接
<5>ifconfig br0 down #停止设备工作
<8> brctl delbr br0 #删除网桥
<11> brctl show
方法2(以文件的形式,永久的):
###此实验在真机里操作,手残党请谨慎操作###
<1>cd /etc/sysconfig/network-scripts/
<2>ls
<3>mv ifcfg-br0 ifcfg-enp0s25 /opt/
<4>ls
<5>nm-connection-editor
<7>vim ifcfg-br0
<8>systemctl stop NetworkManager.service #此服务是图形界面的网络管理服务,当它和正常的网络服务相互冲突时有时会出现问题
<9>systemctl restart network
<10>brctl show
<1>rm -fr ifcfg-br0 ifcfg-enp2s0
<2>mv /opt/ifcfg-* /etc/sysconfig/network-scripts/
<3>systemctl start NetworkManager.service
<4>systemctl restart network