BiroTiket

Thursday 2 August 2012

script update ddns mikrotik v 5.9 untuk changeip.com


TEST WORK ON MIKROTIK V 5.9


# Set your specific ChangeIP.com preferences here.
:global ddnsuser "username"
:global ddnspass "password"
:global ddnshost "domainname"
:local ddnsport 80

# do not let this script run more than once per 3-5 minutes.

:log info "DDNS: Starting."

:global ddnscheckpoint
:if ([:typeof $ddnscheckpoint] = "time") do={
:log info ("DDNS: Last check was " . ([/system clock get time] - $ddnscheckpoint))
} else={
:log info "DDNS: Cannot determine checkpoint, set now."
:global ddnscheckpoint ( [/system clock get time] - 1d )
}

:if ([/system clock get time] - $ddnscheckpoint > [:totime 180s] || [/system clock get time] - $ddnscheckpoint < [:totime 0s]) do={
   :log info "DDNS: Performing remote IP detection."
   /tool fetch address="ip.changeip.com" host="ip.changeip.com" src-path=("/?" . [/int eth get 0 mac-address ]) dst-path="ip.changeip.com.txt" mode=http port=$ddnsport
   :global ddnscheckpoint [/system clock get time]
} else={
   :log info "DDNS: Please be considerate and wait a few seconds longer."
   :break
}

:global ddnslastip
:local html [/file get "ip.changeip.com.txt" contents]
:local ddnsip [:pick $html ([:find $html "<!--IPADDR="] + 11) [:find $html "-->"] ]

:if ([:typeof [:toip $ddnsip]] = "ip" AND $ddnsip != $ddnslastip ) do={
:log info "DDNS: Sending UPDATE with $ddnsip"
:log info [/tool dns-update name=$ddnshost address=$ddnsip key-name=$ddnsuser key=$ddnspass ]
:global ddnslastip $ddnsip
} else={
:log info "DDNS: No update required."
}
}


/system scheduler
add comment="changeip" disabled=no interval=5m name=DDNS on-event=\
    updateip policy=read,write,policy,test,password start-time=\
    startup

No comments:

Post a Comment