noip mikrotik ddns

Mikrotik NOIP update script


##############Script Settings##################

:local NOIPUser "username"
:local NOIPPass "password"
:local WANInter "ether1"

###############################################

:local NOIPDomain "noiphostmane"

###############################################


:local IpCurrent [:resolve myip.opendns.com server=208.67.222.222];
:put $IpCurrent

:if ([:resolve $NOIPDomain] != $IpCurrent) do={
      /tool fetch mode=http user=$NOIPUser password=$NOIPPass url="http://dynupdate.no-ip.com/nic/update\3Fhostname=$NOIPDomain&myip=$Ipcurrent" keep-result=no
      :log info "NO-IP Update: $NOIPDomain - $IpCurrent"
}

:local IpCurrent [:resolve myip.opendns.com server=208.67.222.222];
:put $IpCurrent

:if ([:resolve $NOIPDomain] != $IpCurrent) do={
      /tool fetch mode=http user=$NOIPUser password=$NOIPPass url="http://dynupdate.no-ip.com/nic/update\3Fhostname=$NOIPDomain&myip=$Ipcurrent" keep-result=no
      :log info "NO-IP Update: $NOIPDomain - $IpCurrent"
}

Script for Mikrotik Terminal

/system script
add name=noipupdate source="##############Script Settings###############\
    ###\r\
    \n\r\
    \n:local NOIPUser \"username\"\r\
    \n:local NOIPPass \"password\"\r\
    \n:local WANInter \"ether1\"\r\
    \n\r\
    \n###############################################\r\
    \n\r\
    \n:local NOIPDomain \"noiphostname\"\r\
    \n\r\
    \n:local IpCurrent [:resolve myip.opendns.com server=208.67.222.222];\r\
    \n:put \$IpCurrent\r\
    \n\r\
    \n:if ([:resolve \$NOIPDomain] != \$IpCurrent) do={\r\
    \n      /tool fetch mode=http user=\$NOIPUser password=\$NOIPPass url=\"http://dynupdate.no-ip.com/nic/update\\3Fhostname=\$NOIPDomain&myip=\$Ipcurrent\" \
    keep-result=no\r\
    \n      :log info \"NO-IP Update: \$NOIPDomain - \$IpCurrent\"\r\
    \n}\r\
    \n\r\
    \n"

Now create schedule to run noipupdate min update time 6min. Below 6Min update may be ban your hostname

Best Regard’s
Abubaker Siddiq Lasania
Virtual IT Support

Join in @ Page / Group

Dynamic DNS Update Script for NO-IP behind NAT on Mikrotik Router V2


Dynamic DNS Update Script for NO-IP behind NAT on Mikrotik Router V2

Mikrotik Script format direct paste into script section


#Dynamic DNS Update Script for No-IP DNS behind nat
# Set needed variables
:local username "your no-ip user login"
:local password "your no-ip password"
:local host "your no-ip host name"
:global previousIP
# print some debug info
:log info ("Update No-IP DNS: username = $username")
:log info ("Update No-IP DNS: hostname = $host")
:log info ("Update No-IP DNS: previousIP = $previousIP")
#
# behind nat - get the public address using dyndns url http://checkip.dyndns.org
/tool fetch mode=http address="checkip.dyndns.org" src-path="/" dst-path="/dyndns.checkip.html"
:delay 2
:local result [/file get dyndns.checkip.html contents]
:log info "dyndns result = $result"
# 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 "No-IP DNS: currentIP = $currentIP"
:if ($currentIP != $previousIP) do={
:log info "No-IP: Current IP $currentIP is not equal to previous IP, update needed"
:set previousIP $currentIP
:local url "http://dynupdate.no-ip.com/nic/update/?myip=$currentIP&hostname=$host"
:log info "No-IP DNS: Sending update for $host"
/tool fetch url=$url user=$username password=$password mode=http dst-path=("no-ip_ddns_update.txt")
:log info "No-IP DNS: Host $host updated on No-IP with IP $currentIP"
:delay 2
:local result [/file get "no-ip_ddns_update.txt" contents]
:log info "Update Result = $result"
} else={
:log info "No-IP: update not needed "
}
# end

Mikrotik Terminal Export Format

/system script
add name=noip_ddns policy="read,write,policy" source="#Dynamic DNS Update Script for No-IP DNS beh\
    ind nat\r\
    \n# Set needed variables\r\
    \n:local username \"your no-ip user login\"\r\
    \n:local password \"your no-ip password\"\r\
    \n:local host \"your no-ip host name\"\r\
    \n:global previousIP\r\
    \n# print some debug info\r\
    \n:log info (\"Update No-IP DNS: username = \$username\")\r\
    \n:log info (\"Update No-IP DNS: hostname = \$host\")\r\
    \n:log info (\"Update No-IP DNS: previousIP = \$previousIP\")\r\
    \n#\r\
    \n# behind nat - get the public address using dyndns url http://checkip.dyndns.org\r\
    \n/tool fetch mode=http address=\"checkip.dyndns.org\" src-path=\"/\" dst-path=\"/dyndns.checkip.html\"\r\
    \n:delay 2\r\
    \n:local result [/file get dyndns.checkip.html contents]\r\
    \n:log info \"dyndns result = \$result\"\r\
    \n# parse the current IP result\r\
    \n:local resultLen [:len \$result]\r\
    \n:local startLoc [:find \$result \": \" -1]\r\
    \n:set startLoc (\$startLoc + 2)\r\
    \n:local endLoc [:find \$result \"</body>\" -1]\r\
    \n:local currentIP [pick \$result \$startLoc \$endLoc]\r\
    \n:log info \"No-IP DNS: currentIP = \$currentIP\"\r\
    \n:if (\$currentIP != \$previousIP) do={\r\
    \n:log info \"No-IP: Current IP \$currentIP is not equal to previous IP, update needed\"\r\
    \n:set previousIP \$currentIP\r\
    \n:local url \"http://dynupdate.no-ip.com/nic/update/\?myip=\$currentIP&hostname=\$host\"\r\
    \n:log info \"No-IP DNS: Sending update for \$host\"\r\
    \n/tool fetch url=\$url user=\$username password=\$password mode=http dst-path=(\"no-ip_ddns_update.txt\")\r\
    \n:log info \"No-IP DNS: Host \$host updated on No-IP with IP \$currentIP\"\r\
    \n:delay 2\r\
    \n:local result [/file get \"no-ip_ddns_update.txt\" contents]\r\
    \n:log info \"Update Result = \$result\"\r\
    \n} else={\r\
    \n:log info \"No-IP: update not needed \"\r\
    \n}\r\
    \n# end\r\