2012年4月13日 星期五

RouterOS NO-IP DDNS設定


# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # EDIT YOUR DETAILS / CONFIGURATION HERE # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Define DDNS Accounts for RB Interfaces, one per interface. # The RB interface :global ddnsinterface "ether1" # The DDNS Provider (Choice of NOIP, DYNDNS or EVERYDNS) :global ddnsprovider "NOIP" # The Hostname to update. :global ddnshost "NOIPHOST" # Your Account Username :global ddnsuser "NOIPUSER" # Your Account Password :global ddnspass "NOIPPASS" # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # END OF USER DEFINED CONFIGURATION # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Define Global Variables :global ddnssystem ("mt-" . [/system package get system version] ) :global ddnsip :global ddnslastip :if ([ :typeof $ddnslastip ] = nil ) do={ :global ddnslastip "0" } :if ($ddnsprovider = "NOIP") do={ :global $ddnsprovname "NoIP" :global str "/nic/update?hostname=$ddnshost&myip=$ddnsip" :global $ddnsprovaddress "dynupdate.no-ip.com" } elseif ($ddnsprovider = "DYNDNS") do={ :global $ddnsprovname "DynDNS" :global str "/nic/update?hostname=$ddnshost&myip=$ddnsip&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG" :global $ddnsprovaddress "members.dyndns.org" } elseif ($ddnsprovider = "EVERYDNS") do={ :global $ddnsprovname "EveryDNS" :global str "/index.php?ver=0.1&ip=$ddnsip&domain=$ddnshost" :global $ddnsprovaddress "dyn.everydns.net" } # Grab the current IP address on that interface. :global ddnsip [ /ip address get [/ip address find interface=$ddnsinterface ] address ] # Did we get an IP address to compare? :if ([ :typeof $ddnsip ] = nil ) do={ :log info ("NoIP: No ip address present on " . $ddnsinterface . ", please check.") } else={ :if ($ddnsip != $ddnslastip) do={ :log info $ddnsprovname.": Sending UPDATE!" /tool fetch address=$ddnsprovaddress src-path=$str mode=http user=$ddnsuser password=$ddnspass dst-path=("/DDNS-".$ddnsprovname.".".$ddnshost) } :delay 1 :local str [/file find name="$ddnsprovider.$ddnshost"]; /file remove $str :global ddnslastip $ddnsip } }
參考資料:
http://forum.mikrotik.com/viewtopic.php?f=9&t=36840

http://blog.u-fox.net/613/%E6%95%99%E5%AD%B8scriptsdynamic-dns-update-script-for-no-ip-uo

沒有留言:

張貼留言