您的位置:首页 > 其它

dd-wrt自动更新ddns

2018-04-03 13:05 211 查看
准备脚本

添加到路由器启动脚本

通过web接口

通过nvram命令

路由器重启,不能及时更新ip到dns,如何解决,下面方法可以解决。前提是已经注册了ddns网站,获得ddns域名,在dd-wrt路由上正确配置了ddns。ddns通过手动更新可以获得正常域名ip匹配,现在需要自动更新,即设备重启后更新。

准备脚本

提供ddns解析的网站一般提供更新脚本,譬如

http://freedns.afraid.org/dynamic/index.php

提供有wget,curl,cron等脚本示例,根据自己路由器支持程度,选择合适的脚本

sleep 36
wget -q  -t=400  http://freedns.afraid.org/dynamic/update.php?dksiejlsfkdielakielskjfielakdfie[/code] 
每个注册用户的脚本是不同,请复制粘贴自己的脚本。

sleep 是必须的,否则不能正常启动脚本。

下面是花生壳的

wanip=$(nvram get wan_ipaddr)
wget -q -O /var/log/hsk.log http://用户名:密码@ddns.oray.com/ph/update?hostname=花生壳域名&myip=$wanip >/dev/null 2>&1


添加到路由器启动脚本

https://www.dd-wrt.com/wiki/index.php/Startup_Scripts

两个方法

通过web接口

Using the Web Interface, goto the Administration tab.

If available, go to the Command subtab, otherwise go to the diagnostics subtab.

Type the commands you wish to run every startup into the Commands: dialog box (place each command on a newline using the enter key, and if the command isn’t something that stops running after a moment, put a ‘&’ after the command)

Click the Save Startup button at the bottom of the page if you’d like the commands to save into the rc_startup variable (you may need to scroll). Save Firewall will save the commands into the rc_firewall variable.

通过nvram命令

Login to your router using Telnet/SSH

To set the startup scripts, use the following:

nvram set rc_startup="
<command 1>
<command 2>
...
<command n>
"


When you give the commandnvram commit the rc_startup
9e34
variable is saved in flash memory and will remain when you reboot.

nvram commit
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: