配置网络参数 多个自定义配置文件可能存在针对相同参数的不同配置值,文件名以 zz 开头是期望推荐配置值最终生效。 参考: cat <<'EOT' >"${netplanconfigdir}zzctims.yaml" network: renderer: NetworkManager ethernets: eth0: addresses: [] dhcp4: true dhcp6: true optional: true dhcp4overrides: routemetric: 100 dhcp6overrides: routemetric: 100 version: 2 EOT elif [ f "$networkinterfaceconfig" ]; then [ ! f "${networkinterfaceconfig}.bak" ] &&; cp "$networkinterfaceconfig" "${networkinterfaceconfig}.bak" cat < "$networkinterfaceconfig" This file describes the network interfaces available on your system and how to activate them. For more information, see interfaces(5). source $networkinterfaceconfig.d/ The loopback network interface auto lo iface lo inet loopback EOT systemctl disable networking else echo 'ERROR: Failed to decide a network configuration system.' fi 通用网络配置 1. 配置 sysctl 支持IPv6功能,如果没有使用IPv6的需求,可以跳过此步骤。 plaintext 多个自定义配置文件可能存在针对相同参数的不同配置值,文件名以 zz 开头是期望推荐配置值最终生效。 参考: cat <<'EOT' >/etc/sysctl.d/zzctims.conf net.ipv6.conf.all.acceptra1 net.ipv6.conf.all.disableipv60 net.ipv6.conf.default.acceptra1 net.ipv6.conf.default.disableipv60 net.ipv6.conf.eth0.acceptra1 net.ipv6.conf.lo.disableipv60 EOT 2. 添加补充配置网络的文件。 Red Hat系列Linux操作系统需要下载99gennetconf.rules.zip文件(请解压后提取99gennetconf.rules文件)后,传入虚拟机 /etc/udev/rules.d/ 目录下,作为 /etc/udev/rules.d/99gennetconf.rules 文件。Debian系列Linux操作系统不需要配置。 3. 修改自定义网络脚本目录下的文件权限。 plaintext chmod 755 /usr/local/ctcloud/net/.sh