Dynamic DNS of changeip on RouterOS 6.30.1
本帖最後由 角色 於 2016-2-23 11:37 編輯
Besides the official hostname adddress you can use your own hostname, for example www.changeip.com, which provides many sub-domains you can choose.
Procedure:
1. Goto [System]->[Scripts]
2. Press <+>, it gives a dialog box
3. Put the following code to script window box
4. Name the script, e.g. changeip
5. Click <Run Script> to check whether the code works as expected- #------------------------------------------
- # EDIT YOUR DETAILS / CONFIGURATION HERE
- #------------------------------------------
- :global ddnsuser "your_changeip_login_name"
- :global ddnspass "password"
- :global ddnshost "registered_hostname"
- :global ddnsinterface "ether1_port"
- #------------------------------------------
- # END OF USER DEFINED CONFIGURATION
- #------------------------------------------
- :global ddnssystem ("mt-" . [/system package get [/system package find name=system] version] )
- :global ddnsip [ /ip address get [/ip address find interface=$ddnsinterface] address ]
- :global ddnslastip
- :if ([:len [/interface find name=$ddnsinterface]] = 0 ) do={ :log info "DDNS: No interface named $ddnsinterface, please check configuration." }
- :if ([ :typeof $ddnslastip ] = "nothing" ) do={ :global ddnslastip 0.0.0.0/0 }
- :if ([ :typeof $ddnsip ] = "nothing" ) do={
- :log info ("DDNS: No ip address present on " . $ddnsinterface . ", please check.")
- } else={
- :if ($ddnsip != $ddnslastip) do={
- :log info "DDNS: Sending UPDATE!"
- :log info [ :put [/tool dns-update name=$ddnshost address=[:pick $ddnsip 0 [:find $ddnsip "/"] ] key-name=$ddnsuser key=$ddnspass ] ]
- :global ddnslastip $ddnsip
- } else={
-
- :log info "DDNS: No changes necessary."
- }
- }
複製代碼 When you are happy with the above code, then you can create a scheduled task for the system.
Procedure:
1. [System]->[Scheduler]
2. Put the code "/system script run changeip"
Remarks:
If the router is connected to the Internet via the DHCP method, then
ddnsinterface = ether1-gateway
If the router is connected to the Internet via the PPPoE method, then
ddnsinterface = pppoe-out1 |
附件:
您需要登錄才可以下載或查看附件。沒有帳號?註冊