大网数据广告活动
服务器运维问答

Netplan doesn't delete bond interface when removed from config

· 52CE 我爱测

I have a working bond config, set via Netplan Example, netplan config: network: bonds: bond0: addresses: [10.10.10.135/26] gateway4: 10.10.10.128 interfaces: [ens1f0, ens1f1] nameservers: addresses: [8.8.8.8, 8.8.4.4] parameters:…

问题原文

原帖链接 · Rino Bino · CC BY-SA 4.0

I have a working bond config, set via Netplan

Example, netplan config:

network:
  bonds:
    bond0:
      addresses: [10.10.10.135/26]
      gateway4: 10.10.10.128
      interfaces: [ens1f0, ens1f1]
      nameservers:
        addresses: [8.8.8.8, 8.8.4.4]
      parameters: {mii-monitor-interval: 100, mode: 802.3ad, transmit-hash-policy: layer3+4}
  ethernets:
    ens1f0: {dhcp4: false}
    ens1f1: {dhcp4: false}
  version: 2

Then I update Netplan config to no longer use a bond:

network:
  ethernets:
    ens1f0: {dhcp4: true}
    ens1f1: {dhcp4: true}
  version: 2

When I apply the netplan config, the individual ethernet interfaces are configured properly, but the bond is not deleted from the system.

I have to manually delete it, ex: ip link delete dev bond0

Why is this? Is there a way to make Netplan apply the config exactly as defined?

已采纳解答

原帖链接 · Brandon Harrison · CC BY-SA 4.0

The issue that you're facing is included by design. See the Known Issues portion of the netplan-apply manpage:

KNOWN ISSUES
       netplan  apply will not remove virtual devices such as bridges and bonds that have been created,
       even if they are no longer described in the netplan configuration.  That is due to the fact that
       netplan operates statelessly and is not aware of the previously defined virtal devices.

       This  can  be  resolved  by manually removing the virtual device (for example ip link delete dev
       bond0) and then running netplan apply, by rebooting, or by creating a temporary  backup  of  the
       YAML  state in /etc/netplan before modifying the configuration and passing this state to netplan
       (e.g.  mkdir -p /tmp/netplan_state_backup/etc &&  cp  -r  /etc/netplan  /tmp/netplan_state_back‐
       up/etc/ then running netplan apply –state /tmp/netplan_state_backup)

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2022-05-13)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。