diff --git a/initrd-network.sh b/initrd-network.sh index 6836278..a73fc24 100644 --- a/initrd-network.sh +++ b/initrd-network.sh @@ -442,6 +442,7 @@ fi netconf="/dev/netconf/$ethx" mkdir -p "$netconf" $dhcpv4 && echo 1 >"$netconf/dhcpv4" || echo 0 >"$netconf/dhcpv4" +$dhcpv6_or_slaac && echo 1 >"$netconf/dhcpv6_or_slaac" || echo 0 >"$netconf/dhcpv6_or_slaac" $should_disable_ra_slaac && echo 1 >"$netconf/should_disable_ra_slaac" || echo 0 >"$netconf/should_disable_ra_slaac" $is_in_china && echo 1 >"$netconf/is_in_china" || echo 0 >"$netconf/is_in_china" echo "$ethx" >"$netconf/ethx" diff --git a/trans.sh b/trans.sh index a3c823c..611e67b 100644 --- a/trans.sh +++ b/trans.sh @@ -612,6 +612,12 @@ is_staticv6() { return 1 } +is_dhcpv6_or_slaac() { + get_netconf_to dhcpv6_or_slaac + # shellcheck disable=SC2154 + [ "$dhcpv6_or_slaac" = 1 ] +} + should_disable_ra_slaac() { get_netconf_to should_disable_ra_slaac # shellcheck disable=SC2154 @@ -619,8 +625,9 @@ should_disable_ra_slaac() { } is_slaac() { + # 如果是静态(包括自动获取到 IP 但无法联网而切换成静态)直接返回 1,不考虑 ra # 防止部分机器slaac/dhcpv6获取的ip/网关无法上网 - if should_disable_ra_slaac; then + if ! is_dhcpv6_or_slaac; then return 1 fi get_netconf_to slaac @@ -629,8 +636,9 @@ is_slaac() { } is_dhcpv6() { + # 如果是静态(包括自动获取到 IP 但无法联网而切换成静态)直接返回 1,不考虑 ra # 防止部分机器slaac/dhcpv6获取的ip/网关无法上网 - if should_disable_ra_slaac; then + if ! is_dhcpv6_or_slaac; then return 1 fi get_netconf_to dhcpv6