找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 28239|回复: 22

[脚本] changeip不会被拉黑的DDNS更新脚本V3-V5。解决抱怨changeip不稳定的小白

  [复制链接]
发表于 2013-4-10 22:03:41 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

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

×
本帖最后由 host2318 于 2013-4-10 22:06 编辑

changeip本身相当靠谱,出现故障可能是地域性问题,或者操作不当引起

changeip有限制同一个域名更新频率。如果单位时间内,更新次数太多,这个域名会被拉黑名单,导致更新不到

解决的办法很简单,在计划任务内设置间隔时间长一点即可。

并附DDNS更新脚本两个。分别用于更新V3.X和V4&V5版本的。都是全自动的,不需要设置接口,会自动侦测默认路由的接口
3.x的脚本不知道是哪位编写的
V4&V5的脚本是changeip官方提供的,下载地址“http://www.changeip.com/mikrotik/
V3.X脚本如下

  1. :global ddnsuser "用户名"
  2. :global ddnspass "密码"
  3. :global ddnshost "域名"
  4. :global ddnsip
  5. :global ddnslastip
  6. :if ([ :typeof $ddnslastip ] = nil ) do={ :global ddnslastip "0" }
  7. :global ddnsinterface
  8. :global ddnssystem ("mt-" . [/system package get system version] )
  9. :local int
  10. :foreach int in=[/ip route find dst-address=0.0.0.0/0 active=yes ] do={
  11.   :if ([:typeof [/ip route get $int routing-mark ]] != str ) do={
  12.      :global ddnsinterface [/ip route get $int interface]
  13.   }
  14. }
  15. :global ddnsip [ /ip address get [/ip address find interface=$ddnsinterface ] address ]
  16. :if ([ :typeof $ddnsip ] = nil ) do={
  17.    :log info ("DDNS: No ip address present on " . $ddnsinterface . ", please check.")
  18. } else={
  19.   :if ($ddnsip != $ddnslastip) do={
  20.     :log info "\BF\AA\CA\BC\B8\FC\D0\C2\D4\B6\B3\CC\D3\F2\C3\FB"
  21.     :log info [ :put [/tool dns-update name=$ddnshost address=[:pick $ddnsip 0 [:find $ddnsip "/"] ] key-name=$ddnsuser key=$ddnspass ] ]
  22.     :global ddnslastip $ddnsip
  23.   } else={
  24.     :log info "ip\B5\D8\D6\B7\CE\DE\B1\E4\BB\AF,\D3\F2\C3\FB\B2\BB\D3\C3\B8\FC\D0\C2"
  25.   }
  26. }
  27. #end
复制代码
V4&V5脚本如下
  1. /system script
  2. add name=HomingBeacon policy=\
  3.     ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api \
  4.     source="# HomingBeacon Main Dynamic DNS Update Script\r\
  5.     \n# Written by Sam Norris, ChangeIP.com\r\
  6.     \n# 20100728 Tested on routeros 4.9\r\
  7.     \n# 20110511 Tested on RouterOS 5.2\r\
  8.     \n\r\
  9.     \n# Set your specific ChangeIP.com preferences here.\r\
  10.     \n:global ddnsuser "USERID"\r\
  11.     \n:global ddnspass "PASSWORD"\r\
  12.     \n:global ddnshost "HOSTNAME.changeip.net"\r\
  13.     \n# Change ddnsport to 8245 to bypass proxy.\r\
  14.     \n:local ddnsport 80\r\
  15.     \n\r\
  16.     \n# Do not edit anything below this line.  You have been warned.\r\
  17.     \n# Abusive updates to the system will cause firewall blocks.\r\
  18.     \n\r\
  19.     \n# Please be considerate and\r\
  20.     \n# do not let this script run more than once per 3-5 minutes.\r\
  21.     \n\r\
  22.     \n:log info "DDNS: Starting."\r\
  23.     \n\r\
  24.     \n# Initialize checkpoint\r\
  25.     \n:global ddnscheckpoint\r\
  26.     \n:if ([:typeof \$ddnscheckpoint] = "time") do={\r\
  27.     \n\t:log info ("DDNS: Last check was " . ([/system clock get time] - \$d\
  28.     dnscheckpoint))\r\
  29.     \n} else={\r\
  30.     \n\t:log info "DDNS: Cannot determine checkpoint, set now."\r\
  31.     \n\t:global ddnscheckpoint ( [/system clock get time] - 1d )\r\
  32.     \n}\r\
  33.     \n\r\
  34.     \n# Get the current IP\r\
  35.     \n:if ([/system clock get time] - \$ddnscheckpoint > [:totime 180s] || [/s\
  36.     ystem clock get time] - \$ddnscheckpoint < [:totime 0s]) do={\r\
  37.     \n   :log info "DDNS: Performing remote IP detection."\r\
  38.     \n   /tool fetch address="ip.changeip.com" host="ip.changeip.com" src-\
  39.     path=("/\?" . [/int eth get 0 mac-address ]) dst-path="ip.changeip.com.\
  40.     txt" mode=http port=\$ddnsport\r\
  41.     \n   :global ddnscheckpoint [/system clock get time]\r\
  42.     \n} else={\r\
  43.     \n   :log info "DDNS: Please be considerate and wait a few seconds longer\
  44.     ."\r\
  45.     \n   :break\r\
  46.     \n}\r\
  47.     \n\r\
  48.     \n# Parse the IP address received from fetch script.\r\
  49.     \n\t:global ddnslastip\r\
  50.     \n\t:local html [/file get "ip.changeip.com.txt" contents]\r\
  51.     \n\t:local ddnsip [:pick \$html ([:find \$html "<!--IPADDR="] + 11) [:fi\
  52.     nd \$html "-->"] ]\r\
  53.     \n\r\
  54.     \n# Is it a valid IP and is it different than the last one\?\r\
  55.     \n\t:if ([:typeof [:toip \$ddnsip]] = "ip" AND \$ddnsip != \$ddnslastip \
  56.     ) do={\r\
  57.     \n\t\t:log info "DDNS: Sending UPDATE with \$ddnsip"\r\
  58.     \n\t\t:log info [/tool dns-update name=\$ddnshost address=\$ddnsip key-nam\
  59.     e=\$ddnsuser key=\$ddnspass ]\r\
  60.     \n\t\t:global ddnslastip \$ddnsip\r\
  61.     \n\t} else={\r\
  62.     \n\t\t:log info "DDNS: No update required."\r\
  63.     \n\t}\r\
  64.     \n}\r\
  65.     \n"
复制代码
routeros
 楼主| 发表于 2013-4-10 22:11:28 | 显示全部楼层
本帖最后由 host2318 于 2013-4-10 22:13 编辑

并以附件形式提供V3和更高版本的ddns脚本

V3&V4V5DDNS全自动更新脚本.zip (2.12 KB, 下载次数: 182)
routeros
回复

使用道具 举报

发表于 2013-4-11 01:18:10 | 显示全部楼层
changeip是什么东西。从来没用过。
routeros
回复

使用道具 举报

发表于 2013-4-11 06:50:34 | 显示全部楼层
楼主整理的很好,收藏感谢
routeros
回复

使用道具 举报

发表于 2013-4-11 11:04:12 | 显示全部楼层
这是个好东西
routeros
回复

使用道具 举报

发表于 2013-4-11 12:20:59 | 显示全部楼层
第一个脚本明显有错误。运行失败
routeros
回复

使用道具 举报

发表于 2013-4-11 14:56:01 | 显示全部楼层
用得少肯定靠谱,如果一个帐号里面有8个DDNS需要ROS来运行,每个间隔两分钟,你试试看你的脚本问题还是DDNS问题,DDNS不稳定一方便是解析时间太频繁,另一方面确实是DDNS服务器有问题
routeros
回复

使用道具 举报

 楼主| 发表于 2013-4-11 19:11:19 | 显示全部楼层
routeros
回复

使用道具 举报

 楼主| 发表于 2013-4-11 19:14:37 | 显示全部楼层
persist86 发表于 2013-4-11 14:56
用得少肯定靠谱,如果一个帐号里面有8个DDNS需要ROS来运行,每个间隔两分钟,你试试看你的脚本问题还是DDNS ...

免费版的一个账号好像只能7个域名

真不是我挑毛病。

点评

记不太清楚了,大概就是7到8个吧  发表于 2013-4-11 19:53
routeros
回复

使用道具 举报

发表于 2013-4-11 20:17:50 | 显示全部楼层
先上福利:
未命名.jpg
事实上,还有这样一个原因:

即使CHANGEIP更新成功,你的ROS通过国内DNS服务器得到的动态域名的解析IP,有可能是未作更新的,反应迟缓甚至不会更新,这应该是国内DNS服务器的问题,或被污染了。
我已经多次发现,即使手动到CHANGEIP上去更新了IP地址,国内的DNS还是历经很长时间不会更新。

这个是身不由己的!!
routeros
回复

使用道具 举报

发表于 2013-4-11 20:33:53 | 显示全部楼层
arainbow 发表于 2013-4-11 20:17
先上福利:

事实上,还有这样一个原因:

同感,原因不明
routeros
回复

使用道具 举报

 楼主| 发表于 2013-4-11 22:29:41 | 显示全部楼层
arainbow 发表于 2013-4-11 20:17
先上福利:

事实上,还有这样一个原因:

在自己电脑上更新不到可以尝试重启本机的 dnscache 服务 。WIN系统下
routeros
回复

使用道具 举报

发表于 2013-5-16 10:05:28 | 显示全部楼层
感谢楼主的整理
routeros
回复

使用道具 举报

发表于 2013-5-16 12:36:47 | 显示全部楼层
整理的非常不错,谢谢
routeros
回复

使用道具 举报

发表于 2015-6-11 11:31:54 | 显示全部楼层
就用以前最简单的一优脚本就行
routeros
回复

使用道具 举报

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

本版积分规则

QQ|Archiver|手机版|小黑屋|软路由 ( 渝ICP备15001194号-1|渝公网安备 50011602500124号 )

GMT+8, 2024-5-2 22:26 , Processed in 0.096699 second(s), 6 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2023 Discuz! Team.

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