链路聚合:
两种连接方式:Bond和Team
1.Bond网络
网卡bond是通过把多张网卡绑定为一个逻辑网卡,实现本地网卡的冗余,带宽扩容和负载均衡。在应用部署中是一种常用的技术。
三种绑定方式:
(1)模式 0(平衡轮循)-轮询策略,所有接口都工作,负责一部分工作
(2)模式 1 (主动备份)-容错。一次有一个接口工作,如果该接口出现故障,另一个接口将接替它(active-backup)
(3)模式 3 (广播)-容错。所有封包都通过所有Slave 接口广播
设置步骤:
(1)ifconfig ##查看网卡
(2)nm-connection-editor,清空网络配置
(3)nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 172.25.254.113 ##添加一个bond网络接口(nmcli connection 添加一个连接,add con-name bond0添加连接的名称为bond0,ifname bond0接口名称为bond0, type bond 设备类型为bond mode active-backup模式为轮询)
(4)nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0 #添加eth0
(5)nmcli connection add con-name eth1 ifname eth1 type bond-slave master bond0 #添加eth1
(6)ifconfig eth0 down ##将eth0接口关闭
(7)nmcli connection delete bond0 ##删除bond0
nmcli connection delete eth0
nmcli connection delete eth1
1、添加两片网卡,并查看网卡信息
2.清空网卡配置
3、添加网络接口
4、监控
5、添加eth0
6、添加eth1
7、这当一块网卡损坏时,另一份网卡工作。访问并不会间断。
2.Team 接口
Team 和bond0功能相似
Team 不需要手动加载相应内核模块
Team 有更强的扩展性
支持 8 快网卡
Team 的种类
broadcast 广播容错
roundrobin 平衡轮叫
activebackup 主备
loadbalance 负载均衡
设置步骤:
nmcli connection add con-name team0 ifname team0 type team config '{"runner": {"name":"activebackup"}}' ip4 172.25.254.113/24 ##添加team0
ifconfig
watch -n 1 teamdctl team0 stat ##监控
nmcli connection add con-name eth0 ifname eth0 type team-slave master team0##添加eth0
nmcli connection add con-name eth0 ifname eth0 type team-slave master team0##添加eth1
ifconfig eth0 down
ifconfig eth0 up
准备工作和添加bond0一样
一、添加team0
二、ifconfig查看
三、监控
四、添加eth0
五、添加eth1
六、ifconfig eth0 down (eth1自动顶上去,访问不会间断)
七、ifconfig eth0 up (eth0 修复完成后就会自动成为备份,访问还是通过eth1)
网桥
搭建网桥(在真机上,以root用户)
准备工作:
cd /etc/sysconfig/network-scripts/
cp ifcfg-br0 ifcfg-enp0s25 /mnt -p ##将ifcfg-br0、ifcfg-enp0s25备份到 /mnt 中
nm-connection-editor ##删除网卡信息
shutdown -r now ##重启主机
更改配置文件设置
1. cd /etc/sysconfig/network-scripts
2. vim ifcfg-westos
内容: BOOTPROTO=none
NAME=westos
DEVICE=enp0s25
ONBOOT=yes
BRIDGE=br0
3. vim ifcfg-br0 ##添加桥接br0配置文件
内容: DEVICE=br0
IPADDR=172.25.254.13
PREFIX=24
ONBOOT=yes
BOOTPROTO=none
TYPE=Bridge
4. systemctl stop NetworkManger ##关闭网络管理服务
systemctl restart network ##重启网络服务
brctl show ##查看桥接设置
桥接br0的添加和删除
添加:
brctl show ##查看桥接及设备信息
brctl addbr br0 ##添加桥接br0
brctl addif br0 eth0 ##将br0添加到真实物理设备中
添加步骤
brctl show ##查看桥接信息
bectl addbr br0 ##添加桥接br0
brctl show
ifconfig ##发现并没有IP
ifconfig br0 172.25.254.113/24 ##给br0配置临时ip
ifconfig
ping 172.25.254.x ##无法ping通,因为br0未连接真实设备
brctl addif br0 eth0 ##将br0添加到eth0中
brctl show
ping 172.25.254.x ##可以ping通
删除:
brctl delif br0 eth0 ##将br0从物理设备eth0移除
brctl delbr br0 ##删除桥接br0
删除步骤
brctl show
brctl delif br0 eth0 ##将br0从物理设备eth0移除
brctl delbr br0 ##删除桥接br0 发现报错,因为br0正在使用
ifconfig br0 down ##将br0关掉
ifconfig ##查看
brctl delbr br0 ##删除桥接br0 成功
brctl show