返回列表 發帖
不是放在Files?

TOP

按照#6帖的信息,然后manual行了一次都不行。

TOP

回復 16# 角色

不是.
Welcome to my TaoBao shop: http://mandymak520.taobao.com/

TOP

我用的不是DYNDNS主要domain,而是它的sub-domain,所以script需要某种改变才可以。

TOP

回復 12# bky16

我怎样做都不行!真的纳闷!

TOP

原来的我加的script从来都没有excute过,因为我在log看不到logged messagess。

TOP

终于把Dynamic DNS搞好了。主要是怎样execute问题。

1. 先用Windows Editor把script copied 到Editor里,然后save a file name. Extension可以用什么都可以,一般txt,或者rsc。
2. 怎样execute是一个非常重要的问题,就是用
  1. /import file=script.rsc
複製代碼

TOP

本帖最後由 角色 於 2013-9-8 21:31 編輯

#1帖的code,出现error message
  1. [admin@MikroTik] > /import file-name=dyndns-1.rsc
  2. Opening script file dyndns-1.rsc

  3. Script file loaded successfullyinput does not match any value of value-name
  4. interrupted
  5. [admin@MikroTik] >
複製代碼

TOP

本帖最後由 角色 於 2013-9-8 21:32 編輯

#3帖的code,没有问题
  1. [admin@MikroTik] > /import file-name=dyndns-3.rsc
  2. Opening script file dyndns-3.rsc

  3.   status: finished

  4.   status: finished

  5. Dyndns Update Result: good 58.153.xxx.yyy
  6. Script file loaded and executed successfully
  7. [admin@MikroTik] >
複製代碼

TOP

本帖最後由 角色 於 2013-9-8 21:40 編輯

Another Script Link provided by member "bky16"
  1. ############
  2. # Set needed variables
  3. ############
  4. # Your DynDNS account user-name, password & host-name.
  5. :local username "yourusername"
  6. :local password "yourpassword"
  7. :local hostname "yourhostname"

  8. # Which interface are we checking if DHCP has changed? [interfaces | name column in winbox]
  9. :local DHCPInterface "yourinterface"
  10. ############
  11. # This is the name of the file where the last recorded IP will be stored, as well as the file name of the DynDNS response.
  12. # Make sure if another script is using files, that these names don't conflict.
  13. # You probably also want to be sure they aren't the same as any other files on the disk - because you'll be clobbering those files.
  14. # Finally, while I'm not aware of any "reserved" file names on the disk, it would be wise to avoid something that might conflict.
  15. # Prefixing them with something to associate them with this script would probably be a good thing.
  16. # You can point these files at your SD-disk too, if you have an SD card installed and ready on your RB. Just prefix the path appropriately:
  17. # something like this [:local vLastIPFileName "micro-sd/dyndns-lastip.txt"] (don't put a leading slash)
  18. # A user reported a bug if you use the RB flash and prefix the path with a [/]
  19. # So for RB based flash, it's probably safest to use just something like [:local vLastIPFileName "dyndns-lastip.txt"] and not [:local vLastIPFileName "/dyndns-lastip.txt"]
  20. # You ***MUST*** use a .txt extension. Just an oddity of ROS. Move along now.
  21. # Code ForDD
  22. :local vLastIPFileName "dyndns-lastip.txt"
  23. :local vDynDNSResponseFile "dyndns-resp.txt"
  24. # /dyndns.txt

  25. ############
  26. # END Set needed variables
  27. ############

  28. :local vlen;
  29. :local vRawIP;
  30. :local vJustIP;
  31. :local currentIP
  32. :local previousIP
  33. :local vlocalurl
  34. :local vIPChanged false
  35. :local dyndnsresult
  36. :local result

  37. # Check for file existance, if not create it
  38. # We need to do this before we try to read or write to files...
  39. :local check [/file find name=$vLastIPFileName]
  40. :if ( $check = "" ) do= {
  41.    /file print file=$vLastIPFileName
  42.    :delay 2
  43.    /file set [/file find name=$vLastIPFileName] contents=""
  44. }

  45. # Get the last saved IP from the file.
  46. :set previousIP [/file get $vLastIPFileName contents]
  47. #:put $previousIP


  48. # print some debug info
  49. :log info ("UpdateDynDNS: username = $username")
  50. :log info ("UpdateDynDNS: password = $password")
  51. :log info ("UpdateDynDNS: hostname = $hostname")
  52. :log info ("UpdateDynDNS: previousIP = $previousIP")
  53. :log info ("UpdateDynDNS: DHCPInterface = $DHCPInterface")


  54. # This code gets the current IP from the interface.
  55. # The interface we're checking should be set above.
  56. # get the raw IP from the interface, which includes a mask.
  57. :set vRawIP [:tostr [/ip address get [find interface=$DHCPInterface] address]]

  58. #Strip the netmask off the vRawIP address.
  59. :for i from=( [:len $vRawIP] - 1) to=0 do={
  60.         :if ( [:pick $vRawIP $i] = "/") do={
  61.                 :set vJustIP [:pick $vRawIP 0 $i]
  62.         }
  63. }
  64. :set currentIP $vJustIP

  65. # Determine if dyndns update is needed
  66. # more dyndns updater request details http://www.dyndns.com/developers/specs/syntax.html
  67. # Update if the currentIP isn't equal to previousIP.
  68. :if (($currentIP != $previousIP)) do={
  69.         :log info "CurrentIP: $currentIP - PreviousIP: $previousIP"
  70.         :set vlocalurl ("http://" . "$username" . ":" . "$password" . "@" . "members.dyndns.org" . "/nic/update?hostname=" . "$hostname" . "&myip=" . "$currentIP")   
  71.         /tool fetch mode=http url=$vlocalurl dst-path=$vDynDNSResponseFile
  72.         :set result [/file get $vDynDNSResponseFile contents]
  73.         :set vIPChanged true
  74. } else={
  75.    :log info ("UpdateDynDNS: No dyndns update needed")
  76. }

  77. # Get the result status code and pull it out for use.
  78. # IF IPChanged = true
  79. #        Get result code
  80. #                Check DynDNS result
  81. #                if good or nochg, then
  82. #                        :set previousIP $currentIP
  83. #                        /file set [/file find name=$vLastIPFileName] contents="$currentIP"
  84. #                        also post the result to the log file        
  85. #                else badauth or !donator or notfqdn, nohost, abuse, dnserr, 911
  86. #                        post to log file
  87. #                        Don't update previousIP or vLastIPFileName file
  88. :if ($vIPChanged=true) do={
  89.         :set result [/file get $vDynDNSResponseFile contents]
  90.         :local endLoc [:find $result " " -1]
  91.         :set dyndnsresult [:pick $result -1 ($endLoc)]
  92.         :put $dyndnsresult
  93.                 :if (($dyndnsresult = "good") || ($dyndnsresult = "nochg") ) do={
  94.                         :set previousIP $currentIP
  95.                         :log info ("UpdateDynDNS: Dyndns update needed")
  96.                         :log info ("UpdateDynDNS: Dyndns Update Result: ".$result)
  97.                         /file set [/file find name=$vLastIPFileName] contents="$currentIP"
  98.                         } \
  99.                 else={
  100.                         :log info ("UpdateDynDNS: Dyndns update needed")
  101.                         :log info ("DynDNS Update FAILED")
  102.                         :log info ("UpdateDynDNS: Dyndns Update Result: ".$result)
  103.                 }
  104. }
複製代碼
  1. New Terminal> /system scheduler add name=dyndns interval=00:01 on-event="/system script run dyndns\r\n"
複製代碼
Result 也 Okay
  1. [admin@MikroTik] > /import dyndns-bk.rsc
  2. Opening script file dyndns-bk.rsc

  3.   status: finished

  4. good
  5. Script file loaded and executed successfully
  6. [admin@MikroTik] >
複製代碼

TOP

现在bky16的script,一关电源,过了一晚,再试就没有把DNS更改。

那么估计还要修改一下。

TOP

现在正在测试bubblestar兄的script,看看关机后,再开是否可以把ip upgrade到最新的IP。

TOP

我用1樓的SCRIPT去UPDATE DYNDNS, 幾個月前試都OK, 因為之前一直甪HKBB,所以IP都無轉過, 現在改用PCCW,就發現UPDATE唔到, 點睇SCRIPT是否成功.
角色C兄, 應該要把SCRIPT放到SCHEDULE去RUN, 我每幾分鐘RUN一次,
睇過SCHEDULE的確有RUN到, 但睇唔到個SCRIPT有無成功UPDATE..

TOP

我也发现这个问题,问题是整个script都是看local file,而不是check DNS Server!所以等我有空的时候去学怎样去修改那段script,看看是否做到script去check DNS Server。

TOP

我也发现这个问题,问题是整个script都是看local file,而不是check DNS Server!所以等我有空的时候去学怎 ...
角色 發表於 2013-9-19 22:15



    個script有check dyndns有無update到, 如果wan ip唔等於dyndns records就會update, 但係行完個script都無update到..

TOP

返回列表