arIpAddress 函数默认通过外网获取路由器的地址, 这对于校园网等城域网内部的路由器来说是错误的. 因此我们修改这部分代码. ssh 登录到路由器, 修改文件 /etc/storage/ddns_script.sh , 注释掉下面代码的第5-16行, 在第17行添加查询 man 口(10...* 这样的IP地址)地址的命令.
# 自行测试哪个代码能获取正确的IP,删除前面的#可生效arIpAddress () {# IPv4地址获取# 获得外网地址#curltest=`which curl`#if [ -z "$curltest" ] || [ ! -s "`which curl`" ] ; then# wget --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 --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 --no-check-certificate --quiet --output-document=- "ip.6655.com/ip.aspx" | grep -E -o '([0-9]+\.){3}[0-9]+' | head -n1 | cut -d' ' -f1#wget --no-check-certificate --quiet --output-document=- "ip.3322.net" | 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 -k -s "http://members.3322.org/dyndns/getip" | grep -E -o '([0-9]+\.){3}[0-9]+' | head -n1 | cut -d' ' -f1#curl -k -s ip.6655.com/ip.aspx | grep -E -o '([0-9]+\.){3}[0-9]+' | head -n1 | cut -d' ' -f1#curl -k -s ip.3322.net | grep -E -o '([0-9]+\.){3}[0-9]+' | head -n1 | cut -d' ' -f1#fiifconfig eth3 | grep addr | grep -E -o '([0-9]+\.){3}[0-9]+' | sed -n '1p'}arIpAddress6 () {# IPv6地址获取# 因为一般ipv6没有nat ipv6的获得可以本机获得ifconfig $(nvram get wan0_ifname_t) | awk '/Global/{print $3}' | awk -F/ '{print $1}'}if [ "$IPv6" = "1" ] ; thenarIpAddress=$(arIpAddress6)elsearIpAddress=$(arIpAddress)fi
