找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 7069|回复: 3

[脚本] 官方DDNS更新no-ip做法

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

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

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

×
12.jpg
  1. #定义 no.ip 相关设定,以下自行修改:
  2. #============================================================
  3. :local DDNSUser "no-ip帐号"
  4. :local DDNSPassword "no-ip密码"
  5. :local DDNSHost "申请的no-ip地址"
  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. :local url "/nic/update?hostname=$DDNSHost&myip=$DDNSIP"
  30. /tool fetch address=dynupdate.no-ip.com src-path=$url mode=http user=$DDNSUser password=$DDNSPassword dst-path=("DDNS_no_ip")
  31. :delay 1

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

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

  37. # 变更是否成功
  38. :if ( [ :find $filestr "good"] = "0" || [ :find $filestr "nochg"] = "0" ) do={
  39. :log warning ("DDNS no.ip: 网络更新 IP 位址 " . $DDNSIP)
  40. :set DDNSLastIP $DDNSIP
  41. } else={
  42. :log error ("DDNS no.ip: 网络更新 IP 位址失败 " . $DDNSIP)
  43. }
  44. }
  45. }
  46. #------------------------------------------------------------------------------------------
复制代码
routeros
发表于 2013-10-31 18:23:48 | 显示全部楼层
强!!!!!!!
马上试试,之前版主那个,用不了,这个试试,多谢
routeros
回复

使用道具 举报

发表于 2013-11-14 10:25:05 | 显示全部楼层
又多一个选择,谢谢
routeros
回复

使用道具 举报

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

本版积分规则

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

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

Powered by Discuz! X3.5 Licensed

© 2001-2023 Discuz! Team.

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