Linux系统网络高级配置

一、链路聚合

链路聚合定义

链路聚合,是指将多个物理端口捆绑在一起,成为一个逻辑端口,

以实现出入流量在各成员端口中的负荷分担

二、bond接口

1.建立bond接口

实验虚拟机准备两块网卡,删除所有网络,建立bond0接口,命令如下:
1)nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 172.25.254.248/24

##设置ip为172.25.254.248,子网延码为255.255.255.0,接口名称为bond0的bond主备模式网络配置

2)nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0

##添加bond0的子设备,其网络接口和设备名称均为eth0

3)nmcli connection add con-name eth1 ifname eth1 type bond-slave master bond0

##添加bond1的子设备,其网络接口和设备名称均为eth1

设置完成如下:

Linux系统网络高级配置
 

监控:watch -n 1 cat /proc/net/bonding/bond0

 

Linux系统网络高级配置

 

ifconfig eth0 down,停止eth0工作,eth1顶替继续工作

 

Linux系统网络高级配置

 

ifconfig eth0 up,重新开启eth0,eth1继续工作不会被eth0代替工作

 

Linux系统网络高级配置

 

只有eth1停止工作,eth0才会顶替继续工作

 

Linux系统网络高级配置

eth0与eth1交替工作

 

2.删除bond接

nmcli connection delete bond0    ##删除bond0接口

nmcli connection delete eth0       ##删除eth0网卡接口

nmcli connection delete eth1       ##删除eth1网卡接口
 

三、team接口

team与bond功能类似,区别在于team接口不需要手动加载内核模块,支持8块网卡,而bond接口最多只支持两块网卡

1.建立team接口

1)nmcli connection add con-name team0 ifname team0 type team config '{"runner":{"name":"activebackup"}}' ip4 172.25.254.148/24

Linux系统网络高级配置
2)nmcli connection add con-name eth0 ifname eth0 type team-slave master team0


3)nmcli connection add con-name eth1 ifname eth1 type team-slave master team0

Linux系统网络高级配置
 

查看:teamdctl team0 stat

 

Linux系统网络高级配置

测试:

Linux系统网络高级配置

 

ifconfig eth0 down,停止eth0工作,eth1顶替继续工作

 

Linux系统网络高级配置
 

删除team接口:

nmcli connection delete team0    ##删除team0接口

nmcli connection delete eth0       ##删除eth0网卡接口

nmcli connection delete eth1       ##删除eth1网卡接口

Linux系统网络高级配置

四、网桥管理

1.真机中进行网桥建立

cd /etc/sysconfig/network-scripts/
mkdir /backup
mv ifcfg-br0  ifcfg-enp0s25   /backup/

Linux系统网络高级配置
nm-connection-editor  打开网络图形配置,删除除了virbr0和virbr1的所有接口信息

Linux系统网络高级配置

 

编写配置文件:vim/etc/sysconfig/network-scripts/ifcfg-br0和vim/ifcfg-enp0s25建立网桥
 

Linux系统网络高级配置


brctl show   ##显示网桥

Linux系统网络高级配置


还原先前备份的网卡接口

rm -fr ifcfg-br0 ifcfg-eth0
mv /backup/* .
systemctl restart network

Linux系统网络高级配置

2.搭建临时网桥

brctl addbr br0                                 ##添加br0桥接接口

ifconfig br0 172.25.254.248/24    ##设定br0接口的IP和子网延码

brctl addif br0 eth0                         ##将br0接口添加到网卡设备eth0上

Linux系统网络高级配置

删除临时网桥

Linux系统网络高级配置

Linux系统网络高级配置