返回列表 發帖
本帖最後由 fems 於 2015-1-7 19:21 編輯

一直用DNSexit,免费稳定,也支持顶级域名。
更新脚本参考http://forum.mikrotik.com/viewtopic.php?t=65013修改一下即可,需指定wan口。
ROS6.24

  1. #************************************************************************************************
  2. # Parameters
  3. #************************************************************************************************
  4. :local username "<your username>"
  5. :local password "<your password>"
  6. :local hostname "<subdomain.yourprovider.net>"

  7. #availabe options: "http" or "iface"
  8. # - http: will query an external server and discover you public ip (userful for NATted connections)
  9. # - iface: will use the ip address assigned to the $iface interface (see below)

  10. :local discoverBy "iface"

  11. # interface used to get ip address from (only if discoverBy = iface)

  12. :local iface "public-dsl"

  13. # current available services: "dyndns", "noip" and "dnsexit"
  14. :local service "dnsexit"

  15. # number of days to force an update if your IP did not change (helps keeping your account active)
  16. :local forceUpdate 15

  17. #************************************************************************************************
  18. # do not change below this unless you know what you are doing
  19. #************************************************************************************************

  20. :local force
  21. :global lastUpdate
  22. :local currentIP

  23. :if ($discoverBy="http") do={
  24.    /tool fetch mode=http address="checkip.dyndns.org" src-path="/" dst-path="/dyndns.checkip.html"
  25.    :local result [/file get dyndns.checkip.html contents]
  26.    :local resultLen [:len $result]
  27.    :local startLoc [:find $result ": " -1]
  28.    :set startLoc ($startLoc + 2)
  29.    :local endLoc [:find $result "</body>" -1]
  30.    :set currentIP [:pick $result $startLoc $endLoc]
  31. } else={
  32.    :set currentIP [ /ip address get [find interface=$iface disabled=no] address ]
  33.    :for i from=( [:len $currentIP] - 1) to=0 do={
  34.       :if ( [:pick $currentIP $i] = "/") do={ :set currentIP [:pick $currentIP 0 $i] }
  35.    }
  36. }

  37. #get IP from DynDNS for our hostname
  38. :local resolvedIP [:resolve $hostname]

  39. # get current date in format mm/DD/YYYY
  40. :local date [ /system clock get date ]

  41. # convert to YYYYMMDD
  42. :local months ("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");
  43. :local month [ :pick $date 0 3 ]; :local day [ :pick $date 4 6 ]; :local year [ :pick $date 7 11 ];
  44. :local mm ([ :find $months $month -1 ] + 1);
  45. :if ($mm < 10) do={ :set month ("0" . $mm); } else={ :set month $mm; }
  46. :set date ($year . $month . $day);

  47. :if ([ :typeof $lastUpdate ]=[:nothing] || (($date-$lastUpdate) >= $forceUpdate  && $forceUpdate > 0)) do={
  48.    :set force true
  49. }

  50. :put ("Current IP: $currentIP ($discoverBy), Last update: $lastUpdate")

  51. # Determine if dyndns update is needed
  52. :if (($currentIP != $resolvedIP) || ($force = true)) do={
  53.    
  54.     :if ($service = "dyndns") do={
  55.        /tool fetch user=$username password=$password mode=http address="members.dyndns.org" \
  56.             src-path="/nic/update?hostname=$hostname&myip=$currentIP" dst-path="/output.txt"
  57.     }
  58.     :if ($service = "noip") do={
  59.        /tool fetch user=$username password=$password mode=http address="dynupdate.no-ip.com" \
  60.             src-path="/nic/update?hostname=$hostname&myip=$currentIP" dst-path="/output.txt"
  61.     }
  62.     :if ($service = "dnsexit") do={
  63.        /tool fetch user=$username password=$password mode=http address="update.dnsexit.com" \
  64.             src-path="/RemoteUpdate.sv?login=$username&password=$password&host=$hostname&myip=$currentIP" dst-path="/output.txt"
  65.     }
  66.    
  67.     :local result [/file get output.txt contents]
  68.     :log info ("dynamic-dns-updater: Service = $service, Hostname = $hostname")
  69.     :log info ("dynamic-dns-updater: CurrentIP = $currentIP, Resolved IP = $resolvedIP")
  70.     :log info ("dynamic-dns-updater: Update result: ".$result)
  71.     /ip dns cache flush
  72.     :set lastUpdate $date
  73. }
複製代碼
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

TOP

返回列表