# 本腳本使用了Enom的官方DDNS API;同時 # 本腳本參考了:http://wiki.mikrotik.com/wiki/Dynamic_DNS_Update_Script_for_DNSoMatic.com # 腳本在5.26下測試通過 # Define User Variables # 定義用戶信息 # access.enome.com的登錄密碼 :global ddnspass "xxxx" # 需要設置的域名 :global ddnshost "xxxx" # 外網使用的interface :global inetinterface "pppoe-out1" #https://reseller.enom.com/interface.asp?command=SetDnsHost&Zone=$ddnshost&DomainPassword=$ddnshost&Address=$currentIP # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # END OF USER DEFINED CONFIGURATION # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:global previousIP;
:if ([/interface get $inetinterface value-name=running]) do={ # Get the current IP on the interface :local currentIP [/ip address get [find interface="$inetinterface" disabled=no] address];
# Strip the net mask off the IP address :for i from=( [:len $currentIP] - 1) to=0 do={ :if ( [:pick $currentIP $i] = "/") do={ :set currentIP [:pick $currentIP 0 $i] } }
# The update URL. Note the "\\" is hex for question mark (?). Required since ? is a special character in commands. :log info "EnomDNS: Sending UPDATE!" #請注意下面的"\\"是兩個"\"不是四個,是論壇關係變成四個"\" /tool fetch mode=https url="https://reseller.enom.com/interface.asp\\\\?command=SetDnsHost&Zone=$ddnshost&DomainPassword=$ddnspass&ip=$currentIP" :delay 1 } else={ :log info "EnomDNS: Previous IP $previousIP and current IP equal, no update need" } } else={ :log info "EnomDNS: $inetinterface is not currently running, so therefore will not update." }