This commit is contained in:
spiritlhl 2023-06-24 13:59:17 +00:00
parent 3651120dac
commit 090a37c594

View file

@ -163,6 +163,12 @@ while IFS= read -r line
do
# 检测以 "iface" 开头且包含 "inet6 auto" 的行
if [[ $line == "iface ${interface} inet6 auto" ]]; then
output=$(ip addr)
matches=$(echo "$output" | grep "inet6.*global dynamic")
if [ -n "$matches" ]; then
# SLAAC动态分配做无IPV6的处理
sed -i "/iface $interface inet6 auto/d" $1
else
# 将 "auto" 替换为 "static"
modified_line="${line/auto/static}"
echo "$modified_line"
@ -176,6 +182,7 @@ do
ipv6_gateway=$(ip -6 route show | awk '/default via/{print $3}')
echo " address ${ipv6_address}/${ipv6_prefixlen}"
echo " gateway ${ipv6_gateway}"
fi
else
echo "$line"
fi