LInux的高级网络服务

链路聚合

平衡轮循:传输速率块
主动备份:提高网卡稳定性

bond接口

bond最多支持两块网卡
1)进入虚拟机管理。给虚拟机添加网卡,确保虚拟机有两个网卡
这里写图片描述
这里写图片描述
2)删除所有网络接口
这里写图片描述
3)设定bond接口

watch -n 1 cat /proc/net/bonding/bond0    ##可用此命令监控以下操作
nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 172.25.160.214/24   ##创建一个bonding,设定bond主备模式
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到bond0接口 

这里写图片描述

nmcli connection show               ##查看网卡接口信息
nmcli connection delete             ##删除网卡接口
ifconfig eth0 down | up             ##关闭|打开网卡

这里写图片描述
4)当关闭eth0网卡时会发现eth1会继续顶替eth0继续工作
这里写图片描述
5)当再次打开eth0网卡时eth0并不顶替eth1,而当关闭eth1时会发现eth0又顶替eth1继续工作
这里写图片描述
这里写图片描述

team接口

team功能与bond类似,team最多支持八块网卡
1)与bond一样,确保虚拟机有两个网卡,然后删除所有网络接口
这里写图片描述
2)设定

watch -n 1 teamdctl team0 state      ##监控
nmcli connection add con-name team0 ifname team0 type team config '{"runner":{"name":"activebackup"}}' ip4 172.25.254.114/24              ##建立team接口
nmcli connection add con-name eth0 ifname eth0 type team-slave master team0         ##往team0上添加eth0
nmcli connection add con-name eth1 ifname eth1 type team-slave master team0         ##往team0上添加eth1

这里写图片描述
此时可以ping通真机
这里写图片描述
3)与bond相同,关闭一个网卡,另一个顶替继续工作
这里写图片描述

桥接

搭建网桥

1)为了方便恢复原来网卡配置文件,先把/etc/sysconfig/network-scripts/中相关网卡配置文件移到/mnt/中
这里写图片描述
2)打开网络图形管理删除网络 只留下virbr0和virbr1
这里写图片描述
3)创建相关配置文件

vim /etc/sysconfig/network-scripts/ifcfg-2333    ##创建网卡配置文件,写入下面内容
 BOOTPROTO=none
 BRIDGE=br0
 DEVICE=enp0s25
 ONBOOT=yes

这里写图片描述

vim /etc/sysconfig/network-scripts/ifcfg-br0 ##创建网桥配置文件,写入下面内容
DEVICE=br0
ONBOOT=yes
BOOTPROTO=none
IPADDR=172.25.254.14
PREFIX=24
TYPE=Bridge

这里写图片描述

systemctl restart  network            ##重启网络

3)可以看到br0和enp5s0f1生成
这里写图片描述

临时桥接搭建

1)删除虚拟机所有网络接口
这里写图片描述
2)搭建临时网桥

brctl addbr br0                  ##建立br0
ifconfig br0 172.25.254.114/24   ##给br0设定临时ip
brctl addif br0 eth0             ##给br0添加网卡设备
brctl show                       ##查看

这里写图片描述
删除临时网桥

brctl delif br0 eth0
ifconfig br0 down
brctl delbr br0

这里写图片描述

猜你喜欢

转载自blog.csdn.net/qq657886445/article/details/81546282