core: 添加 ra dns
This commit is contained in:
parent
2fcc131ecb
commit
c30c5ecc4c
@ -77,9 +77,9 @@ fi
|
||||
|
||||
# 如果ipv4/ipv6不联网,则删除该协议的dns
|
||||
if $ipv4_has_internet && ! $ipv6_has_internet; then
|
||||
sed -i '/:/d' /etc/resolv.conf
|
||||
sed -i '/^[[:blank:]]*nameserver[[:blank:]].*:/d' /etc/resolv.conf
|
||||
elif ! $ipv4_has_internet && $ipv6_has_internet; then
|
||||
sed -i '/\./d' /etc/resolv.conf
|
||||
sed -i '/^[[:blank:]]*nameserver[[:blank:]].*\./d' /etc/resolv.conf
|
||||
fi
|
||||
|
||||
# 如果联网了,但没获取到默认 DNS,则添加我们的 DNS
|
||||
|
8
trans.sh
8
trans.sh
@ -279,6 +279,7 @@ EOF
|
||||
echo "$ra" | cat -n
|
||||
echo "$ra" | grep 'Autonomous address conf' | grep Yes && is_slaac=true
|
||||
echo "$ra" | grep 'Stateful address conf' | grep Yes && is_dhcpv6=true
|
||||
ra_dns=$(echo "$ra" | grep 'Recursive DNS server' | cut -d: -f2- | xargs)
|
||||
fi
|
||||
|
||||
# 删除临时安装的软件,不然会带到新系统
|
||||
@ -306,6 +307,13 @@ EOF
|
||||
fi
|
||||
fi
|
||||
|
||||
# udhcpc/dhcpcd + slaac,不会自动写入ra dns
|
||||
# 如果有ra dns,则删除自己添加的dns,再添加ra dns
|
||||
if [ -n "$ra_dns" ]; then
|
||||
sed -i '/^[[:blank:]]*nameserver[[:blank:]].*:/d' /etc/resolv.conf
|
||||
echo "nameserver $ra_dns" >>/etc/resolv.conf
|
||||
fi
|
||||
|
||||
ip addr
|
||||
cat -n /etc/network/interfaces
|
||||
rc-update add networking boot
|
||||
|
Loading…
Reference in New Issue
Block a user