From f822eea94e4f01b1dfb57bf3f38d856539ca9faf Mon Sep 17 00:00:00 2001 From: bin456789 Date: Sun, 14 Apr 2024 21:05:18 +0800 Subject: [PATCH] =?UTF-8?q?centos=207:=20=E9=81=BF=E5=85=8D=20yum=20?= =?UTF-8?q?=E5=9C=A8=E6=B2=A1=20ipv6=20=E7=9A=84=E6=83=85=E5=86=B5?= =?UTF-8?q?=E4=B8=8B=E4=BD=BF=E7=94=A8=20ipv6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- alpine-network.sh | 2 ++ trans.sh | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/alpine-network.sh b/alpine-network.sh index 3c52978..86473a7 100644 --- a/alpine-network.sh +++ b/alpine-network.sh @@ -202,3 +202,5 @@ echo "$ipv4_addr" >/dev/ipv4_addr echo "$ipv4_gateway" >/dev/ipv4_gateway echo "$ipv6_addr" >/dev/ipv6_addr echo "$ipv6_gateway" >/dev/ipv6_gateway +$ipv4_has_internet && echo 1 >/dev/ipv4_has_internet || echo 0 >/dev/ipv4_has_internet +$ipv6_has_internet && echo 1 >/dev/ipv6_has_internet || echo 0 >/dev/ipv6_has_internet diff --git a/trans.sh b/trans.sh index 5d77b7a..a0cdf56 100644 --- a/trans.sh +++ b/trans.sh @@ -2059,6 +2059,13 @@ install_qcow_el() { # 部分镜像例如 centos7 要手动删除 machine-id truncate_machine_id /os + # centos 7 yum 可能会使用 ipv6,即使没有 ipv6 网络 + if grep 'centos:7' /os/etc/system-release-cpe; then + if [ "$(cat /dev/ipv6_has_internet)" = "0" ]; then + echo 'ip_resolve=4' >>/os/etc/yum.conf + fi + fi + # 为 centos 7 ci 安装 NetworkManager # 1. 能够自动配置 onlink 网关 # 2. 解决 cloud-init 关闭了 ra,因为 nm 无视内核 ra 设置