chongshengB / rt-n56u

Padavan
1.74k stars 1.63k forks source link

如果通过阿里DDNS访问ipv6 #529

Open boomzikazita opened 3 years ago

boomzikazita commented 3 years ago

我已经在阿里云上解析了我的ipv6地址,但是路由器报错: 【AliDDNS动态域名】: 错误! 获取目前 IPv6 失败,请在脚本更换其他获取地址,保证取得IPv6地址(例如:ff03:0:0:0:0:0:0:c1)

alepc-cn commented 2 years ago

我用的这个可行,你试一下,

自行测试哪个代码能获取正确的IP,删除前面的#可生效

arIpAddress () {

IPv4地址获取

获得外网地址

curltest=which curl if [ -z "$curltest" ] || [ ! -s "which curl" ] ; then

wget -T 5 -t 3 --no-check-certificate --quiet --output-document=- "https://www.ipip.net" | grep "IP地址" | grep -E -o '([0-9]+.){3}[0-9]+' | head -n1 | cut -d' ' -f1

wget -T 5 -t 3 --no-check-certificate --quiet --output-document=- "http://members.3322.org/dyndns/getip" | grep -E -o '([0-9]+\.){3}[0-9]+' | head -n1 | cut -d' ' -f1
#wget -T 5 -t 3 --no-check-certificate --quiet --output-document=- "ip.3322.net" | grep -E -o '([0-9]+\.){3}[0-9]+' | head -n1 | cut -d' ' -f1
#wget -T 5 -t 3 --no-check-certificate --quiet --output-document=- "http://pv.sohu.com/cityjson?ie=utf-8" | grep -E -o '([0-9]+\.){3}[0-9]+' | head -n1 | cut -d' ' -f1

else

curl -L -k -s "https://www.ipip.net" | grep "IP地址" | grep -E -o '([0-9]+.){3}[0-9]+' | head -n1 | cut -d' ' -f1

curl -L -k -s "http://members.3322.org/dyndns/getip" | grep -E -o '([0-9]+\.){3}[0-9]+' | head -n1 | cut -d' ' -f1
#curl -L -k -s ip.3322.net | grep -E -o '([0-9]+\.){3}[0-9]+' | head -n1 | cut -d' ' -f1
#curl -L -k -s http://pv.sohu.com/cityjson?ie=utf-8 | grep -E -o '([0-9]+\.){3}[0-9]+' | head -n1 | cut -d' ' -f1

fi } arIpAddress6 () {

IPv6地址获取

因为一般ipv6没有nat ipv6的获得可以本机获得

ifconfig $(nvram get br0_ifname_t) | awk '/Global/{print $3}' | awk -F/ '{print $1}' } if [ "$IPv6" = "1" ] ; then arIpAddress=$(arIpAddress6) else arIpAddress=$(arIpAddress) fi