From 496d2ba5bd351173b4ce02f080c35a834c024ea7 Mon Sep 17 00:00:00 2001 From: akarin233 Date: Thu, 6 Feb 2025 17:15:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20--static=20=E5=8F=82?= =?UTF-8?q?=E6=95=B0=EF=BC=8C=E5=BC=BA=E5=88=B6=E4=BD=BF=E7=94=A8=E9=9D=99?= =?UTF-8?q?=E6=80=81IP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/trans.sh b/trans.sh index bd3e0a2..7aff211 100644 --- a/trans.sh +++ b/trans.sh @@ -581,9 +581,16 @@ is_in_china() { grep -q 1 /dev/netconf/*/is_in_china } +force_static() { + grep -q 1 /dev/netconf/*/force_static +} + # 有 dhcpv4 不等于有网关,例如 vultr 纯 ipv6 # 没有 dhcpv4 不等于是静态ip,可能是没有 ip is_dhcpv4() { + if force_static; then + return 1 + fi get_netconf_to dhcpv4 # shellcheck disable=SC2154 [ "$dhcpv4" = 1 ] @@ -612,12 +619,18 @@ is_staticv6() { } should_disable_ra_slaac() { + if force_static; then + return 1 + fi get_netconf_to should_disable_ra_slaac # shellcheck disable=SC2154 [ "$should_disable_ra_slaac" = 1 ] } is_slaac() { + if force_static; then + return 1 + fi # 防止部分机器slaac/dhcpv6获取的ip/网关无法上网 if should_disable_ra_slaac; then return 1 @@ -628,6 +641,9 @@ is_slaac() { } is_dhcpv6() { + if force_static; then + return 1 + fi # 防止部分机器slaac/dhcpv6获取的ip/网关无法上网 if should_disable_ra_slaac; then return 1