从配置中删除时,Netplan 不会删除绑定接口

从配置中删除时,Netplan 不会删除绑定接口

我有一个有效的债券配置,通过 Netplan 设置

例如,netplan 配置:

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

然后我更新 Netplan 配置以不再使用债券:

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

当我应用 netplan 配置时,各个以太网接口都配置正确,但绑定不会从系统中删除。

我必须手动删除它,例如:ip link delete dev bond0

这是为什么?有没有办法让 Netplan 完全按照定义应用配置?

答案1

您遇到的问题是设计所致。请参阅手册页Known Issues的部分内容netplan-apply

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)

相关内容