ARTICLE
Set No-ip mikrotik
[ 2018-04-27 17:36:17 ]

http://www.wifi4you.com/Amp/no-ip-%E0%B8%81%E0%B8%B1%E0%B8%9A-Mikrotik.html

 

# No-ip DNS control automatic updates
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# EDIT YOUR DETAILS / CONFIGURATION HERE
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:local username "No-IP Username"
:local password "No-IP Password"
:local hostname "Your No-IP Hostname"
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# END OF USER DEFINED CONFIGURATION
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:global dyndnsForce
:global previousIP

# print some debug info
#:log info ("No-IPddns-update: username = $username")
#:log info ("No-IPddns-update: password = $password")
#:log info ("No-IPddns-update: hostname = $hostname")
#:log info ("No-IPddns-update: previousIP = $previousIP")

# get the current IP address from the internet (in case of double-nat)
/tool fetch mode=http address="checkip.dyndns.org" src-path="/" dst-path="/dyndns.checkip.html"
:local result [/file get dyndns.checkip.html contents]

# parse the current IP result
:local resultLen [:len $result]
:local startLoc [:find $result ": " -1]
:set startLoc ($startLoc + 2)
:local endLoc [:find $result "</body>" -1]
:local currentIP [:pick $result $startLoc $endLoc]
:log info "dyndns-update: currentIP = $currentIP"

# Determine if dyndns update is needed
# more dyndns updater request details available athttp://www.dyndns.com/developers/specs/syntax.html
:if (($currentIP != $previousIP) || ($dyndnsForce = true)) do={
    :set dyndnsForce false
    :set previousIP $currentIP
    /tool fetch user=$username password=$password mode=http address="dynupdate.no-ip.com" src-path="/nic/update?hostname=$hostname&myip=$currentIP"
    :local result [/file get dyndns.txt contents]
    :log info ("No-IPddns-update: No-IPddns update needed")
    :log info ("No-IPddns-update: No-IPddns Update Result: ".$result)
    :put ("No-IPddns Update Result: ".$result)
} else={
    :log info ("No-IPddns-update: No No-IPddns update needed")
}
}