netplan 不會在單獨的 YAML 檔案上連接地址

netplan 不會在單獨的 YAML 檔案上連接地址

我正在嘗試使用 netplan 在乙太網路介面中設定附加位址。這男人netplan-generate 的頁面提到相同金鑰配置的序列應該連接起來,但該值總是被覆蓋。

基本 yaml 檔案位於01-network-all.yaml

network:
  ethernets:
    ---other interfaces---
    eth0:
      addresses: [1.1.1.1/24]
  renderer: networkd
  version: 2

我的新設定檔02-example.yaml

network:
  ethernets:
    eth0:
      addresses: [2.2.2.2/24]
  renderer: networkd
  version: 2

每當我執​​行 netplan 生成/應用然後檢查該值時,該地址僅報告為2.2.2.2/24.

輸出--debug意味著 Networkd 正在尋找這兩個條目,但沒有按預期連接它們:

DEBUG:netplan generated networkd configuration changed, restarting networkd
DEBUG:eth0 exists in {'eth0': {'addresses': ['1.1.1.1/24']}}
DEBUG:Merged config:
network:
  ethernets:
    eth0:
      addresses:
      - 2.2.2.2/24
  renderer: networkd
netplan get ethernets.eth0.addresses
- 2.2.2.2/24

這裡發生了什麼事?我檢查了更改是否正在生效,因此並不是網路遊戲未能應用它們。我使用了錯誤的格式?我認為一個序列用[]表示。

作為後續問題,除了這種方式之外,還有其他簡單的方法可以進行此更改嗎?我想用 netplan get 檢索條目,用 shell 命令 ant 處理它,然後用 netplan set 附加新條目,但我將以一個非常髒的 shell 腳本結束。

相關內容