找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 5192|回复: 1

[脚本] 测试可用的NO-IP更新脚本,需要的拿去

[复制链接]
发表于 2013-11-4 17:30:31 | 显示全部楼层 |阅读模式

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

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

×
公司要做一个域名解析,用到NO-IP的动态域名,看到前天这个贴子发的,实验下,不能更新成功。稍微改改动下,可以了。有需要的拿去。
http://bbs.routerclub.com/forum. ... amp;highlight=no-ip
  1. #定义 no.ip 相关设定,以下自行修改:
  2. #============================================================
  3. :local DDNSUser "用户名"
  4. :local DDNSPassword "密码"
  5. :local DDNSHost "你的主机名"

  6. #============================================================
  7. #以下程式如不了解,建议不要修改:
  8. #------------------------------------------------------------------------------------------
  9. #定义 IP 变量
  10. :local DDNSIP
  11. :global DDNSLastIP
  12. #定义变量默认值
  13. :if ([ :typeof $DDNSLastIP ] = nil ) do={ $DDNSLastIP "0.0.0.0" }
  14. #利用HTTP查询Public IP
  15. /tool fetch address=checkip.dyndns.com src-path=/ mode=http dst-path=("PublicIP");
  16. :delay 1;
  17. #读取档案
  18. :set DDNSIP [/file get PublicIP contents];
  19. :set DDNSIP [:pick $DDNSIP 0 [:find $DDNSIP "</body>"]];
  20. :set DDNSIP [:pick $DDNSIP ([:find $DDNSIP ":"]+2) 100];

  21. #删除档案
  22. /file remove PublicIP;
  23. #判断是否要更新 IP

  24. :if ([ :typeof $DDNSIP ] = nil ) do={
  25. :log error ("DDNS no.ip: 网络未取得 IP 位址")
  26. } else={
  27. :if ($DDNSIP != $DDNSLastIP) do={
  28. # 更新 DDNS IP
  29. #这个地方在?号前要国个\才能解析的,只改了这一个地方。
  30. :local url "/nic/update\?hostname=$DDNSHost&myip=$DDNSIP"  
  31. /tool fetch address=dynupdate.no-ip.com src-path=$url mode=http user=$DDNSUser  password=$DDNSPassword dst-path=("DDNS_no_ip")
  32. :delay 1

  33. # 档案内容
  34. :local filestr [ /file get "DDNS_no_ip" contents];

  35. # 删除档案
  36. :local filename [ /file find name="DDNS_no_ip"];
  37. /file remove $filename

  38. # 变更是否成功
  39. :if ( [ :find $filestr "good"] = "0" || [ :find $filestr "nochg"] = "0" ) do={
  40. :log warning ("DDNS no.ip: 网络更新 IP 位址 " . $DDNSIP)
  41. :set DDNSLastIP $DDNSIP
  42. } else={
  43. :log error ("DDNS no.ip: 网络更新 IP 位址失败 " . $DDNSIP)
  44. }
  45. }
  46. }
复制代码
routeros
发表于 2013-11-19 00:47:30 | 显示全部楼层
很需要!但不太懂?不過還是感謝分享!!
routeros
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-18 06:23 , Processed in 0.081110 second(s), 4 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2023 Discuz! Team.

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