欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

虚拟网络接口bond

程序员文章站 2022-07-03 18:25:16
...

Bond 的原理是网卡在混杂 (promisc) 模式下运行;在这种模式下,网卡不像在通常情况下,只接收目的硬件地址是自身 Mac 的以太网帧,对于别的数据帧都滤掉,以减轻驱动程序的负担;而是接收网络上所有的数据帧,而且修改了驱动程序中的 mac 地址,将两块网卡的 Mac 地址改成相同,可以接收特定 mac 的数据帧,然后把相应的数据帧传送给 bond 驱动程序处理。

命令方式管理桥接接口-brctl命令介绍

brctl show             ##查看已有网桥
brctl addbr br0        ##添加网桥
ifconfig br0 172.25.254.232 netmask 255.255.255.0     ##为br0的虚拟网卡配置ip和子网掩码
brctl addif br0 eth0   ##添加一块物理网卡,将它附加到刚生成的虚拟网桥接口br0上

ifconfig br0 down      ##关闭网桥
brctl delif br0 eth0   ##删除物理网卡
brctl delbr br0        ##删除网桥

虚拟网络接口bond
虚拟网络接口bond

网卡的链路聚合-bond

//创建一个bond口,即bond0
nmcli connection add type bond con-name bond0 ifname bond0 mode active-backup ip4 172.25.254.232/24     
//为bond0添加eth1网卡
nmcli connection add con-name eth1 ifname eth1 type bond-slave master bond0 
//为bond0添加eth2网卡 
nmcli connection add con-name eth2 ifname eth2 type bond-slave master bond0 

虚拟网络接口bond

开启监控窗口,查看bond0当前使用状态
虚拟网络接口bond

使用ifconfig eth1 down命令使eht1断开。这里可以看到,只有eth2是活跃状态,而eth1已经显示为断开。
虚拟网络接口bond

网卡的链路聚合-Team接口

Team和bond0功能类似,不过Team不需要手动加载相应的内核模块,并且支持8块网卡,具有更强的拓展性。

//创建一个team设备,即team0
nmcli connection add type team con-name team0 ifname team0 config ‘{“runner”:{“name”:”activebackup”}}’ ip4 172.25.254.232/24 
//将eth0设备加入team0
nmcli connection add con-name eth0 ifname eth0 type team-slave master team0
//将eth1设备加入team0
nmcli connection add con-name eth1 ifname eth1 type team-slave master team0

虚拟网络接口bond

创建一个team0设备,并将两块设备依次加入team0网路组后,使用teamdctl team0 state命令查看team0当前使用状态。
虚拟网络接口bond
测试网络的连通性
虚拟网络接口bond

相关标签: 网卡