alpine: 优化网络配置逻辑

This commit is contained in:
bin456789 2023-08-25 13:39:48 +08:00
parent c830907cef
commit 3bf44504a6
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B

View File

@ -273,28 +273,25 @@ install_alpine() {
sed -i '/^slaac private/s/^/#/' /etc/dhcpcd.conf
sed -i '/^#slaac hwaddr/s/^#//' /etc/dhcpcd.conf
# 生成 lo 配置
# 生成 lo配置 + eth0头部
cat <<EOF >/etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
EOF
# 生成 ipv4 配置
echo >>/etc/network/interfaces
if [ "$(get_netconf dhcpv4)" = 1 ]; then
# dhcpv4
cat <<EOF >>/etc/network/interfaces
auto eth0
iface eth0 inet dhcp
EOF
echo "iface eth0 inet dhcp" >>/etc/network/interfaces
else
# static
ipv4_addr=$(get_netconf ipv4_addr)
ipv4_gateway=$(get_netconf ipv4_gateway)
if [ -n "$ipv4_addr" ]; then
cat <<EOF >>/etc/network/interfaces
auto eth0
iface eth0 inet4 static
iface eth0 inet static
address $ipv4_addr
gateway $ipv4_gateway
EOF