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多会话,万一断线可以直接在另一会话恢复。

相关推荐
A小辣椒1 天前
TShark:Wireshark CLI 功能
linux
A小辣椒1 天前
TShark:基础知识
linux
AlfredZhao1 天前
OCI 明明分配了 200G 系统盘,为什么 df 只看到 30G?
linux·oci
AlfredZhao2 天前
vi 删除指定范围的行,不用再反复按 dd
linux·vi
用户9718356334662 天前
银河麒麟 KY10 申威(SW64) 安装 nginx-1.16.1-2.p01.ky10.sw_64.rpm 详细步骤
linux
猪脚踏浪2 天前
linux 拷贝文件或目录到指定的位置
linux
大树883 天前
金刚石散热越强,管路越先见顶
大数据·运维·服务器·人工智能·ai
摇滚侠3 天前
Linux CentOS7 rpm 安装 MySQL 5.7
linux·运维·mysql
霸道流氓气质3 天前
领域驱动设计(DDD)在 Spring Boot 微服务中的实践指南
运维·spring boot·微服务
bush43 天前
嵌入式linux学习记录十四、术语
linux·嵌入式