From bbdaff7b8cd3ec208399d1d0f7bc9a1ff0d9ddd9 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Tue, 10 Dec 2024 00:23:02 +0800 Subject: [PATCH] =?UTF-8?q?fedora:=20=E4=BF=AE=E5=A4=8D=20dhcpv6=20+=20Net?= =?UTF-8?q?workManager=20=E6=97=A0=E6=B3=95=E8=8E=B7=E5=8F=96=E7=BD=91?= =?UTF-8?q?=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 50 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/trans.sh b/trans.sh index 6ce0c63..0952b24 100644 --- a/trans.sh +++ b/trans.sh @@ -2331,7 +2331,6 @@ EOF fi create_cloud_init_network_config "$ci_file" "$recognize_static6" "$recognize_ipv6_types" - cat -n $ci_file } modify_windows() { @@ -2820,6 +2819,16 @@ EOF # 修复 onlink 网关 add_onlink_script_if_need fi + + # 修复 cloud-init + sysconfig / NetworkManager 的各种网络问题 + if [ -d "$os_dir/etc/sysconfig" ] || [ -d "$os_dir/etc/NetworkManager" ]; then + fix_sysconfig_NetworkManager $os_dir + fi + + # 查看 cloud-init 最终配置 + if [ -f "$ci_file" ]; then + cat -n "$ci_file" + fi } modify_os_on_disk() { @@ -3174,6 +3183,28 @@ is_el7_family() { ! is_have_cmd_on_disk "$1" dnf } +fix_sysconfig_NetworkManager() { + os_dir=$1 + ci_file=$os_dir/etc/cloud/cloud.cfg.d/99_fallback.cfg + + # 删除云镜像自带的 dhcp 配置,防止歧义 + rm -rf $os_dir/etc/NetworkManager/system-connections/*.nmconnection + rm -rf $os_dir/etc/sysconfig/network-scripts/ifcfg-* + + # 1. 修复 cloud-init 添加了 IPV*_FAILURE_FATAL / may-fail=false + # 甲骨文 dhcpv6 获取不到 IP 将视为 fatal,原有的 ipv4 地址也会被删除 + # 2. 修复 dhcpv6 下,ifcfg 添加了 IPV6_AUTOCONF=no 导致无法获取网关 + # 3. 修复 dhcpv6 下,NM method=dhcp 导致无法获取网关 + + insert_into_file $ci_file after '^runcmd:' <