centos 7: 避免 yum 在没 ipv6 的情况下使用 ipv6

This commit is contained in:
bin456789 2024-04-14 21:05:18 +08:00
parent c87b2dd58d
commit f822eea94e
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B
2 changed files with 9 additions and 0 deletions

View File

@ -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

View File

@ -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 设置