From 56f5c90a2659fe87395c1596fb848e53fd28c03f Mon Sep 17 00:00:00 2001 From: bin456789 Date: Wed, 15 Nov 2023 20:46:15 +0800 Subject: [PATCH] =?UTF-8?q?core:=20=E4=BA=91=E9=95=9C=E5=83=8F=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E4=B8=A4=E7=A7=8D=20dns=20=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/trans.sh b/trans.sh index 410ee77..04575f1 100644 --- a/trans.sh +++ b/trans.sh @@ -833,7 +833,8 @@ create_cloud_init_network_config() { yq -i ".network.version=1 | .network.config[0].type=\"physical\" | .network.config[0].name=\"eth0\" | - .network.config[0].mac_address=\"$mac_addr\" + .network.config[0].mac_address=\"$mac_addr\" | + .network.config[1].type=\"nameserver\" " $ci_file ip_index=0 @@ -851,9 +852,13 @@ create_cloud_init_network_config() { \"gateway\": \"$ipv4_gateway\" } " $ci_file + # 旧版 cloud-init 有 bug + # 有的版本会只从第一种配置中读取 dns,有的从第二种读取 + # 因此写两种配置 if dns4_list=$(get_current_dns_v4); then for cur in $dns4_list; do yq -i ".network.config[0].subnets[$ip_index].dns_nameservers += [\"$cur\"]" $ci_file + yq -i ".network.config[1].address += [\"$cur\"]" $ci_file done fi ip_index=$((ip_index + 1)) @@ -893,6 +898,7 @@ create_cloud_init_network_config() { if is_need_manual_set_dnsv6 && dns6_list=$(get_current_dns_v6); then for cur in $dns6_list; do yq -i ".network.config[0].subnets[$ip_index].dns_nameservers += [\"$cur\"]" $ci_file + yq -i ".network.config[1].address += [\"$cur\"]" $ci_file done fi }