mirror of
https://github.com/bin456789/reinstall.git
synced 2025-01-19 04:49:13 +08:00
core: 云镜像配置将静态 dns 绑定到网卡
可修复 fedora (NetworkManager + resolved) 未渲染静态 dns
This commit is contained in:
parent
0abbeb7085
commit
5ab8d279b9
51
trans.sh
51
trans.sh
@ -829,34 +829,34 @@ create_cloud_init_network_config() {
|
|||||||
get_netconf_to mac_addr
|
get_netconf_to mac_addr
|
||||||
apk add yq
|
apk add yq
|
||||||
|
|
||||||
yq -i "
|
# shellcheck disable=SC2154
|
||||||
.network.version=1 |
|
yq -i ".network.version=1 |
|
||||||
.network.config[0].type=\"physical\" |
|
.network.config[0].type=\"physical\" |
|
||||||
.network.config[0].name=\"eth0\" |
|
.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
|
||||||
" $ci_file
|
|
||||||
|
ip_index=0
|
||||||
|
|
||||||
# ipv4
|
# ipv4
|
||||||
if is_dhcpv4; then
|
if is_dhcpv4; then
|
||||||
yq -i ".network.config[0].subnets += [{\"type\": \"dhcp4\"}]" $ci_file
|
yq -i ".network.config[0].subnets[$ip_index] = {\"type\": \"dhcp4\"}" $ci_file
|
||||||
|
ip_index=$((ip_index + 1))
|
||||||
elif is_staticv4; then
|
elif is_staticv4; then
|
||||||
get_netconf_to ipv4_addr
|
get_netconf_to ipv4_addr
|
||||||
get_netconf_to ipv4_gateway
|
get_netconf_to ipv4_gateway
|
||||||
|
yq -i ".network.config[0].subnets[$ip_index] = {
|
||||||
yq -i "
|
\"type\": \"static\",
|
||||||
.network.config[0].subnets += [{
|
\"address\": \"$ipv4_addr\",
|
||||||
\"type\": \"static\",
|
\"gateway\": \"$ipv4_gateway\" }
|
||||||
\"address\": \"$ipv4_addr\",
|
" $ci_file
|
||||||
\"gateway\": \"$ipv4_gateway\" }]
|
|
||||||
" $ci_file
|
|
||||||
|
|
||||||
if dns4_list=$(get_current_dns_v4); then
|
if dns4_list=$(get_current_dns_v4); then
|
||||||
for cur in $dns4_list; do
|
for cur in $dns4_list; do
|
||||||
yq -i ".network.config[1].address += [\"$cur\"]" $ci_file
|
yq -i ".network.config[0].subnets[$ip_index].dns_nameservers += [\"$cur\"]" $ci_file
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
ip_index=$((ip_index + 1))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ipv6
|
# ipv6
|
||||||
@ -866,10 +866,10 @@ create_cloud_init_network_config() {
|
|||||||
else
|
else
|
||||||
type=ipv6_slaac
|
type=ipv6_slaac
|
||||||
fi
|
fi
|
||||||
yq -i ".network.config[0].subnets += [{\"type\": \"$type\"}]" $ci_file
|
yq -i ".network.config[0].subnets[$ip_index] = {\"type\": \"$type\"}" $ci_file
|
||||||
|
|
||||||
elif is_dhcpv6; then
|
elif is_dhcpv6; then
|
||||||
yq -i ".network.config[0].subnets += [{\"type\": \"ipv6_dhcpv6-stateful\"}]" $ci_file
|
yq -i ".network.config[0].subnets[$ip_index] = {\"type\": \"ipv6_dhcpv6-stateful\"}" $ci_file
|
||||||
|
|
||||||
elif is_staticv6; then
|
elif is_staticv6; then
|
||||||
get_netconf_to ipv6_addr
|
get_netconf_to ipv6_addr
|
||||||
@ -882,18 +882,17 @@ create_cloud_init_network_config() {
|
|||||||
else
|
else
|
||||||
type_ipv6_static=static6
|
type_ipv6_static=static6
|
||||||
fi
|
fi
|
||||||
yq -i "
|
yq -i ".network.config[0].subnets[$ip_index] = {
|
||||||
.network.config[0].subnets += [{
|
\"type\": \"$type_ipv6_static\",
|
||||||
\"type\": \"$type_ipv6_static\",
|
\"address\": \"$ipv6_addr\",
|
||||||
\"address\": \"$ipv6_addr\",
|
\"gateway\": \"$ipv6_gateway\" }
|
||||||
\"gateway\": \"$ipv6_gateway\" }]
|
" $ci_file
|
||||||
" $ci_file
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 有 ipv6 但需设置 dns 的情况
|
# 有 ipv6 但需设置 dns 的情况
|
||||||
if is_need_manual_set_dnsv6 && dns6_list=$(get_current_dns_v6); then
|
if is_need_manual_set_dnsv6 && dns6_list=$(get_current_dns_v6); then
|
||||||
for cur in $dns6_list; do
|
for cur in $dns6_list; do
|
||||||
yq -i ".network.config[1].address += [\"$cur\"]" $ci_file
|
yq -i ".network.config[0].subnets[$ip_index].dns_nameservers += [\"$cur\"]" $ci_file
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user