linux基础&NMCLI介绍及作用✍

本文详细介绍网络聚合原理,包括链路聚合模式如广播、轮询、主备及负载均衡等,重点讲解LACP协议与Team配置实战。通过实例演示如何在虚拟机上配置网卡聚合,实现网络链路的高可用性和负载分担。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

**

NetworkManager command line tool

基于会话的网路管理

NetworkManager服务(在后边进行实践时 会用到)
对网络图形界面的管控
network 服务 :代表的是所有的网络服务
二者相比 network的管控范围较大一些

为什么要将网卡聚合绑定?
1.为了保证数据能够安全传输 将网卡绑定;
2.为了保证在大量数据传输时 分担设备的压力 通过多条链路聚合 从而使得如果链路故障时 会存在备份链路承载流量,不会造成更大的影响。

如下图:
在这里插入图片描述
在传输过程中你觉得可以有几种传输方式?

广播模式 Broadcast传输来自所有端口的包 如图中 四条链路都进行传输
轮询模式 roundrobin以轮询的模式传递所有端口的包 如图中 按照一定顺序进行循环
主备模式activebakup设定某条链路为主链路 只有当主链路发生故障时,才会启动备份链路进行数据传输
loadbalance均衡模式监控流量并使用哈希函数以尝试在选择端口的时候达到完美均衡 例如带宽
LACP链路聚合基于IEEE802.3ad标准的LACP(Link Aggregation Control Protocol,链路汇聚控制协议)是一种实现链路动态汇聚的协议。LACP协议通过LACPDU(Link Aggregation Control Protocol Data Unit,链路汇聚控制协议数据单元)与对端交互信息。

点击查看LACP协议介绍

**

team配置网卡聚合链路

**
在这里插入图片描述
创建虚拟网卡 team0 分别将真实的物理网卡加入到 虚拟网卡team0的会话中,从而实现绑定的效果。
下边让我们看看在 虚拟机上如何实现该过程:

**

绑定两个网卡测试

**:

第一步 在主界面进行添加两个网络适配器;模式要求必须一样
在这里插入图片描述
下一步:
在这里插入图片描述
下一步:
在这里插入图片描述
再次以同样的方法进行添加 注意两个网络适配器的模式必须一样
虚拟机自动重启;
也可以在这进行检查你是否添加成功
在这里插入图片描述
开启连接 存在两种方式:
第一种 直接申请ip
[root@localhost ~]# dhclient
在这里插入图片描述
第二种 将每个网络适配器进行手动连接
在这里插入图片描述
查看示例文件
[root@localhost ~]# cd /usr/share/doc/teamd-1.17/example_configs/
进入主备模式的示例文件:
[root@localhost example_configs]# vim activebackup_tipc.conf
在这里插入图片描述
复制其中的内容:
“runner”: {“name”: “activebackup”}
创建新的设备和会话
[root@localhost example_configs]# nmcli connection add type team con-name team1 ifname team1 config ‘{“runner”: {“name”: “activebackup”}}’
成功添加的连接 ‘team1’(59b38026-ad5f-44d9-a084-7735194e30fc)。
在这里插入图片描述
添加设备到team1 (黄色的为会话名称 自己定义)
[root@localhost example_configs]# nmcli connection add type team-slave con-name team1-port1 ifname eno33554984 master team1
成功添加的连接 ‘team1-port1’(9a048613-cf77-4e96-b23b-84aaffb31351)。
[root@localhost example_configs]# nmcli connection add type team-slave con-name team1-port2 ifname eno50332208 master team1
成功添加的连接 ‘team1-port2’(6f6a0e9b-2251-4a5c-b45b-ec8bd9b89592)。
激活从设备
[root@localhost example_configs]# nmcli connection up team1-port1
成功激活的连接(D-Bus 激活路径:/org/freedesktop/NetworkManager/ActiveConnection/10)
[root@localhost example_configs]# nmcli connection up team1-port2
成功激活的连接(D-Bus 激活路径:/org/freedesktop/NetworkManager/ActiveConnection/11)
激活主设备
[root@localhost example_configs]# nmcli connection up team1
Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/12)
查看主设备状态
[root@localhost example_configs]# teamdctl team1 state
在这里插入图片描述
Ip a 查看 team1 设备的IP地址 通过ping测试一下
在这里插入图片描述
主备模式 可以看出现在的主为eno3 所以将eno3停用后 看是否切换到eno5
**

主备模式切换

**
[root@localhost example_configs]# nmcli connection down team1-port1
Connection ‘team1-port1’ successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/13)
[root@localhost example_configs]# teamdctl team1 state
在这里插入图片描述

配置team桥接

虚拟机和window主机的桥接:
在这里插入图片描述

虚拟机 通过
在这里插入图片描述
在这里插入图片描述

首先和上述的方法相同
修改team0 的 配置
[root@localhost example_configs]# nmcli connection modify team1 ipv4.addresses 172.24.8.111/24 ipv4.gateway 172.24.8.1 ipv4.dns 114.114.114.114 ipv4.method manual connection.autoconnect yes
[root@localhost example_configs]# nmcli connection up team1
成功激活的连接(D-Bus 激活路径:/org/freedesktop/NetworkManager/ActiveConnection/11)

因为上边已经创建了team0 则只需在创建一个桥接网卡 与team 设备进行关联即可
[root@localhost example_configs]# nmcli device disconnect team1
Device ‘team1’ successfully disconnected.
[root@localhost example_configs]# systemctl stop NetworkManager
NetworkManager-dispatcher.service NetworkManager.service
[root@localhost example_configs]# systemctl stop NetworkManager.service
[root@localhost example_configs]# systemctl disable
Too few arguments.
[root@localhost example_configs]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# vim ifcfg-team1
在这里插入图片描述

[root@localhost network-scripts]# vim ifcfg-team1-port1
在这里插入图片描述

[root@localhost network-scripts]# vim ifcfg-br0在这里插入图片描述

[root@localhost network-scripts]# systemctl restart NetworkManager
[root@localhost network-scripts]# nmcli device connect team1
Device ‘team1’ successfully activated with ‘81460dd4-acc7-45b3-969b-e059fdaf1ce3’.
查看 检验 :

使用DHCP br0 和 team1 是一样的IP地址
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值