找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 873|回复: 13

通过阿里DDNS如何访问到路由器上的 NAS

[复制链接]
发表于 2022-5-16 08:55 | 显示全部楼层 |阅读模式
本帖最后由 tk72 于 2022-5-16 08:57 编辑

NAS是黑群。要使用阿里DDNS,方法之一是在NAS上设置,不过这个方法需要写脚本,定时在NAS运行,稍微复杂了一些。我现在就是怎么做的,也成功实现了域名访问。我的公网IP是IPV6的,没有IPV4的。

我进入路由器,发现老毛子固件其实已经内置了阿里DDNS,我按图中设置好了之后,也可以通过这里设置的域名访问到本路由器。但能访问路由器不是我的目的,我目的是能访问 NAS
我的想法是,能否不在NAS进行任何设置( 比如定时运行脚本什么的),只在在路由器设置,能不能动态实现NAS动态改变域名对应的IP?(从而实现对NAS的DDNS)

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
我的恩山、我的无线 The best wifi forum is right here.
发表于 2022-5-16 09:02 | 显示全部楼层
可以的,最简单的就是你目前的状态然后关闭防火墙,就可以域名+端口访问了
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-5-16 09:21 | 显示全部楼层
端口转发,域名加端口号就可以了。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-5-16 09:52 | 显示全部楼层
这个教程:https://www.bilibili.com/read/cv14212983
点一下,你截图里的 脚本 Shell,里面修改 黑群设备的mac地址
老毛子 根据 设备mac 获取到 设备的 ipv6 从而更新到域名
然后在 防火墙 里再开启一下端口

点评

谢谢指点与回复。但我遇到麻烦,那个脚本根本不允许我改,鼠标放在脚本框框上是禁止图标。请看7楼  详情 回复 发表于 2022-5-16 12:58
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-5-16 09:57 | 显示全部楼层
就用你图上这个插件,然后在下面脚本里根据提示的格式写上你nas的mac地址就可以使用ipv6了,自动ddns。

还有就是注意域名解析那边要给key id这个子账户解析权限

点评

谢谢指点与回复。但我遇到麻烦,那个脚本根本不允许我改,鼠标放在脚本框框上是禁止图标。请看7楼  详情 回复 发表于 2022-5-16 12:58
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-5-16 10:00 | 显示全部楼层



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×

点评

不知道哪里出问题,首先,脚本不可更改,鼠标变成禁止符号,如图。请问如何修改脚本?路由器已经是admin管理员登录了。 [attachimg]552595[/attachimg] 其次,我的脚本只有这些内容,没有你后面那些。  详情 回复 发表于 2022-5-16 12:52
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2022-5-16 12:52 | 显示全部楼层

不知道哪里出问题,首先,脚本不可更改,鼠标变成禁止符号,如图。请问如何修改脚本?路由器已经是admin管理员登录了。





其次,我的脚本只有这些内容,没有你后面那些。


# 自行测试哪个代码能获取正确的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 -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.6655.com/ip.aspx | 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
fi
}
arIpAddress6 () {
# IPv6地址获取
# 因为一般ipv6没有nat ipv6的获得可以本机获得
ifconfig $(nvram get wan0_ifname_t) | awk '/Global/{print $3}' | awk -F/ '{print $1}'
}
if [ "$IPv6" = "1" ] ; then
arIpAddress=$(arIpAddress6)
else
arIpAddress=$(arIpAddress)
fi



可否把你的脚本后面,关于IPV6设置MAC映射的那部分贴出来?
谢谢

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2022-5-16 12:58 | 显示全部楼层
jjit 发表于 2022-5-16 09:52
这个教程:https://www.bilibili.com/read/cv14212983
点一下,你截图里的 脚本 Shell,里面修改 黑群设备 ...

谢谢指点与回复。但我遇到麻烦,那个脚本根本不允许我改,鼠标放在脚本框框上是禁止图标。请看7楼
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2022-5-16 12:58 | 显示全部楼层
dliner 发表于 2022-5-16 09:57
就用你图上这个插件,然后在下面脚本里根据提示的格式写上你nas的mac地址就可以使用ipv6了,自动ddns。

...

谢谢指点与回复。但我遇到麻烦,那个脚本根本不允许我改,鼠标放在脚本框框上是禁止图标。请看7楼
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-5-16 13:21 | 显示全部楼层
tk72 发表于 2022-5-16 12:58
谢谢指点与回复。但我遇到麻烦,那个脚本根本不允许我改,鼠标放在脚本框框上是禁止图标。请看7楼

# 自行测试哪个代码能获取正确的IP,删除前面的#可生效
arIpAddress () {
# IPv4地址获取
# 获得外网地址
curltest=`which curl`
if [ -z "$curltest" ] || [ ! -s "`which curl`" ] ; then
    wget -T 5 -t 3 --user-agent "$user_agent" --quiet --output-document=- "https://www.cloudflare.com/cdn-cgi/trace" | awk -F= '/ip/{print $2}'
    #wget -T 5 -t 3 --user-agent "$user_agent" --quiet --output-document=- "http://myip.ipip.net" | grep "当前 IP" | grep -E -o '([0-9]+\.){3}[0-9]+' | head -n1 | cut -d' ' -f1
    #wget -T 5 -t 3 --user-agent "$user_agent" --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 --user-agent "$user_agent" --quiet --output-document=- "ip.3322.net" | grep -E -o '([0-9]+\.){3}[0-9]+' | head -n1 | cut -d' ' -f1
    #wget -T 5 -t 3 --user-agent "$user_agent" --quiet --output-document=- "http://ddns.oray.com/checkip" | grep -E -o '([0-9]+\.){3}[0-9]+' | head -n1 | cut -d' ' -f1
else
    curl -L --user-agent "$user_agent" -s "https://www.cloudflare.com/cdn-cgi/trace" | awk -F= '/ip/{print $2}'
    #curl -L --user-agent "$user_agent" -s "http://myip.ipip.net" | grep "当前 IP" | grep -E -o '([0-9]+\.){3}[0-9]+' | head -n1 | cut -d' ' -f1
    #curl -L --user-agent "$user_agent" -s "http://members.3322.org/dyndns/getip" | grep -E -o '([0-9]+\.){3}[0-9]+' | head -n1 | cut -d' ' -f1
    #curl -L --user-agent "$user_agent" -s ip.3322.net | grep -E -o '([0-9]+\.){3}[0-9]+' | head -n1 | cut -d' ' -f1
    #curl -L --user-agent "$user_agent" -s http://ddns.oray.com/checkip | grep -E -o '([0-9]+\.){3}[0-9]+' | head -n1 | cut -d' ' -f1
fi
}
arIpAddress6 () {
# IPv6地址获取
# 因为一般ipv6没有nat ipv6的获得可以本机获得
ifconfig $(nvram get wan0_ifname_t) | awk '/Global/{print $3}' | awk -F/ '{print $1}'
curl -6 -s https://www.cloudflare.com/cdn-cgi/trace | awk -F= '/ip/{print $2}'
}
if [ "$IPv6_neighbor" != "1" ] ; then
if [ "$IPv6" = "1" ] ; then
arIpAddress=$(arIpAddress6)
else
arIpAddress=$(arIpAddress)
fi
else
arIpAddress=$inet6_neighbor
inet6_neighbor=""
IPv6_neighbor=0
fi

# 根据 ip -f inet6 neighbor show 获取终端的信息,设置 ddns 解析,实现每个终端的 IPV6 动态域名
# 参数说明:使用 @ 符号分割,①前缀名称 ②域名 ③MAC【不限大小写】
# ④匹配关键词的ip6地址【可留空】 ⑤排除关键词的ip6地址【可留空】 ⑥手动指定ip【可留空】
# 下面是信号填写例子:(删除前面的#可生效)
cat >/tmp/ip6_ddns.inf <<-\EOF
#www@google.com@09:9B:9A:90:9F9@@fe80:  # 参数填写例子



EOF
cat /tmp/ip6_ddns.inf | grep -v '^#'  | grep -v "^$" > /tmp/ip6_ddns_inf
rm -f /tmp/ip6_ddns.inf

点评

刷另一本版本的固件,可以修改脚本的,已经成功。  详情 回复 发表于 2022-5-18 12:31
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-5-16 13:29 | 显示全部楼层
刷最新hiboy做的老毛子固件:https://www.right.com.cn/forum/thread-3546372-1-1.html

点评

后来研究发现,老毛子的固件要改脚本,必须回到家从真正的内网登录才行。如果用zerotier远程登录,即使用内网IP登录,脚本也是不可改的,鼠标变成禁止图标。  详情 回复 发表于 2022-5-26 08:49
已经成功了。感谢。 我刷的是另一个版本,带ZeroTier的。  详情 回复 发表于 2022-5-18 12:31
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2022-5-18 12:31 | 显示全部楼层
jjit 发表于 2022-5-16 13:29
刷最新hiboy做的老毛子固件:https://www.right.com.cn/forum/thread-3546372-1-1.html

已经成功了。感谢。
我刷的是另一个版本,带ZeroTier的。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2022-5-18 12:31 | 显示全部楼层
dliner 发表于 2022-5-16 13:21
# 自行测试哪个代码能获取正确的IP,删除前面的#可生效
arIpAddress () {
# IPv4地址获取

刷另一本版本的固件,可以修改脚本的,已经成功。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2022-5-26 08:49 | 显示全部楼层
jjit 发表于 2022-5-16 13:29
刷最新hiboy做的老毛子固件:https://www.right.com.cn/forum/thread-3546372-1-1.html

后来研究发现,老毛子的固件要改脚本,必须回到家从真正的内网登录才行。如果用zerotier远程登录,即使用内网IP登录,脚本也是不可改的,鼠标变成禁止图标。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-16 16:09

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表