linux 高级网络配置

链路聚合

1.band

模式 0(平衡轮循)-轮循策略,所有接口都使用轮循方式在所有Slave中传输封包;任何Slave都可以接收
模式 1(主动备份)- 容错。一次只能使用一个Slave接口,但是如果该接口出现故障,另一个Slave将接替它
模式 3(广播) - 容错。所有封包都通过所有Slave接口广播

实现模式1:

准备两个网卡

nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 172.25.254.160/24      

在这里插入图片描述

nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0  ##使网卡eth0为bond0服务
nmcli connection add con-name eth1 ifname eth1 type bond-slave master bond0  ##使网卡eth1为bond1服务

在这里插入图片描述

watch -n1 cat /proc/net/bonding/bond0  ##查看bond0信息

在这里插入图片描述
测试:
ifconfig eth0 down ##关闭网卡eth0
查看网络状态

2.team

Team 接口
Team 和 bond 功能类似
Team 不需要手动加载相应内核模块
Team 有更强的拓展性
支持 8 块网卡
Team 的种类
broadcast  广播容错
roundrobin 平衡轮叫
activebackup 主备
loadbalance  负载均衡
通过nmcli 设定 team
nmcli connection add con-name team0 ifname team0 type team config '{"runner":{"name":"activebackup"}}' ip4 172.25.254.160/24

在这里插入图片描述

nmcli connection add con-name eth0 ifname eth0 type team-slave master team0 ##使eh0为team0服务
nmcli connection add con-name eth0 ifname eth0 type team-slave master team0 ##使eth1为team1服务

在这里插入图片描述

watch -n1 teamdctl team0 stat  ##监测team0 信息

在这里插入图片描述

设置桥接br ##使虚拟机传输数据不用经过真机内核 降低延迟

cd /etc/sysconfig/network-scripts 
vim ifcfg-westos
BOOTPROTO=none
NAME=westos
DEVICE=enp0s25
ONBOOT=yes
BRIDGE=br0

在这里插入图片描述

vim ifcfg-br0             ##与网卡设置中的BRIDGE=br0 名称一致
DEVICE=br0
IPADDR=172.25.254.60
PREFIX=24
ONBOOT=yes
BOOTPROTO=none
TYPE=Bridge                ##使用桥接

在这里插入图片描述

systemctl stop NetworkManager    ##重要的网络设定应关闭
systemctl restart network
brctl show                      ##显示桥接信息

在这里插入图片描述

临时设置桥接

添加桥接

brctl addbr br0

在这里插入图片描述

ifconfig br0 172.25.254.160/24

在这里插入图片描述

brctl addif br0 eth0
brctl show

在这里插入图片描述
删除桥接

brctl delif br0 eth0

在这里插入图片描述

ifconfig br0 down
brctl delbr br0

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/zcx1203/article/details/87392780