From 70e196045cd3a264c3b6d9e937dd154cbbbd50de Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 7 Aug 2026 10:35:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20Ubuntu=20Netplan=20?= =?UTF-8?q?static/dhcp=20=E6=A8=A1=E5=BC=8F=E7=BC=BA=E5=B0=91=20ethernets?= =?UTF-8?q?=20=E5=B1=82=E5=AF=BC=E8=87=B4=20netplan=20apply=20=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 接口名直接挂在 network: 下导致 'unknown key' 错误, 现在正确放在 ethernets: 下面。 --- src/schemas/network-ubuntu-netplan.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/schemas/network-ubuntu-netplan.js b/src/schemas/network-ubuntu-netplan.js index a938f5f..ede872a 100644 --- a/src/schemas/network-ubuntu-netplan.js +++ b/src/schemas/network-ubuntu-netplan.js @@ -250,15 +250,17 @@ export function generateNetworkUbuntuNetplan(config) { const body = [] // 每个元素是一行,已包含完整缩进 if (config.configType === 'static') { - body.push(` ${config.interface}:`) - body.push(...genIp(4)) + body.push(` ethernets:`) + body.push(` ${config.interface}:`) + body.push(...genIp(6)) } else if (config.configType === 'dhcp') { - body.push(` ${config.interface}:`) - body.push(` dhcp4: true`) + body.push(` ethernets:`) + body.push(` ${config.interface}:`) + body.push(` dhcp4: true`) if (dnsList.length > 0) { - body.push(` nameservers:`) - body.push(` addresses:`) - for (const d of dnsList) body.push(` - ${d}`) + body.push(` nameservers:`) + body.push(` addresses:`) + for (const d of dnsList) body.push(` - ${d}`) } } else if (config.configType === 'bond') { const slaves = String(config.bondSlaves || '').split(',').map((s) => s.trim()).filter(Boolean)