ens2f0 IP 远程连线,balance-alb 模式配置双网卡(ens2f0 + ens6f0)Bond,避免断网

1️⃣ 前置条件

  • 当前系统网卡:ens2f0ens6f0

  • 当前远程连接 IP:10.92.128.87(ens2f0)

  • 网关:10.92.128.1

  • DNS:172.20.150.216 172.20.150.217

  • Bond 名称:bond0

  • 模式:balance-alb

  • 确保 NetworkManager 已启用:

    bash 复制代码
    systemctl is-enabled NetworkManager
    # 如果输出不是 enabled,请先启动:
    # systemctl enable --now NetworkManager

2️⃣ 创建 bond0(先不加入原有 IP)

bash 复制代码
nmcli con add type bond con-name bond0 ifname bond0 mode balance-alb connection.autoconnect yes

这时 bond0 已存在,但没有 IP,也不会影响 ens2f0 的远程连接。

3️⃣ 将现有 IP 临时迁移到 bond0

  1. 查看 ens2f0 当前配置
bash 复制代码
nmcli con show ens2f0

假设 IP、网关、DNS 已知:

  • IP: 10.92.128.87/24

  • 网关: 10.92.128.1

  • DNS: 172.20.150.216 172.20.150.217

2.给 bond0 配置相同 IP(不会删除 ens2f0 的 IP):

bash 复制代码
nmcli con mod bond0 ipv4.addresses 10.92.128.87/24
nmcli con mod bond0 ipv4.gateway 10.92.128.1
nmcli con mod bond0 ipv4.dns "172.20.150.216 172.20.150.217"
nmcli con mod bond0 ipv4.method manual
nmcli con up bond0

✅ 现在 bond0 已配置 IP,可以用同样的 IP 远程访问,不会断线

4️⃣ 删除 ens2f0 原有 IP

bash 复制代码
nmcli con mod ens2f0 ipv4.addresses ""
nmcli con mod ens2f0 ipv4.gateway ""
nmcli con down ens2f0

不会断线,因为 bond0 已有 IP。

5️⃣ 将物理网卡加入 bond0

bash 复制代码
nmcli con add type bond-slave con-name bond-slave-ens2f0 ifname ens2f0 master bond0
nmcli con add type bond-slave con-name bond-slave-ens6f0 ifname ens6f0 master bond0

确保两个网卡都设置为 slave 并加入 bond0。

6️⃣ 启用 bond0 和从属网卡

bash 复制代码
nmcli con up bond-slave-ens2f0
nmcli con up bond-slave-ens6f0
nmcli con up bond0

这时 bond0 已经用 balance-alb 模式工作,两张网卡共享 IP。

7️⃣ 验证配置

bash 复制代码
cat /proc/net/bonding/bond0
nmcli con show --active
ip addr show bond0

8️⃣ 永久生效

bash 复制代码
nmcli con mod bond0 connection.autoconnect yes
nmcli con mod bond-slave-ens2f0 connection.autoconnect yes
nmcli con mod bond-slave-ens6f0 connection.autoconnect yes

注意事项 / 避免断网技巧

  1. 永远不要直接删除 ens2f0 IP,必须先把 IP 转移到 bond0。

  2. 上线顺序

    1. 创建 bond0

    2. 配置 IP

    3. 确认可以 ping 通

    4. 删除原物理网卡 IP

    5. 添加 slave

    6. 启用 bond0

  3. 如果是远程操作,建议使用 screen/tmux多会话,万一断线可以直接在另一会话恢复。

相关推荐
Ronin3051 分钟前
【Qt系统相关】Qt系统相关
网络·qt·音视频·多线程·定时器·事件·qt文件
醇氧3 分钟前
【学习】封锁协议
网络·学习·oracle
杜子不疼.4 分钟前
Linux 部署 RocketMQ 实操:从内网到公网,搞定远程消息服务
linux·运维·人工智能·rocketmq
!沧海@一粟!5 分钟前
麒麟V10Sp3系统部署Zabbix7.0全攻略
linux·运维
一叶星殇7 分钟前
解决IIS无法支持APK文件的下载
运维·服务器
YXWik612 分钟前
Linux 环境 libreoffice 执行word转pdf 中文乱码问题
linux·pdf·word
袖手蹲13 分钟前
Arduino UNO Q 板载 Nanobot 自动化编程指南之一
运维·自动化
早安试言13 分钟前
【了解】对话指令详解
服务器·python
老星*14 分钟前
Umami:轻量级开源网站分析工具,打造隐私友好的Google Analytics替代方案
运维·安全·开源
bai_lan_ya15 分钟前
嵌入式linux--文件IO中dup/dup2的使用
linux·运维·服务器