找回密码
 加入网盟
分割线
官方精品推荐
访脚本的主要功能是更新当前IP、DDNS更新回传信息等
方法如下:
1、在/System Script下添加如下脚本内容
  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. }
复制代码


脚本名称命名为noip
2、在/System Scheduler下添加一个脚本定时,名称为noip,内容为noip,执行时间为10分钟(时间可自定义)
注意:单线单拨可用
分享至 : QQ空间
收藏

0 个回复

您需要登录后才可以回帖 登录 | 加入网盟
关闭

华夏网盟推荐 上一条 /1 下一条