Mikrotik Setup Dynamically Changing IP With No-IP Api

Table of Contents

Code

Use the System>Scripts page and create a new script with this code. Change the variables under the Script Settings block. Also, to make things easier, set the name of the script to "NoIP"

Source Page

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

:local NOIPUser "USERNAME"
:local NOIPPass "PASSWORD"
:local WANInter "ether1"
:local NOIPDomain "NO-IP.DDNS.NET"

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

# Get the current IP on the interface
:local currentIP [/ip address get [find interface="$WANInter" 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]
       }
   }

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

Running and Scheduling a Job

You can run the script a single time with this command:

# "NoIP" is the name I set for the script
/system/script/run NoIP

I'd suggest scheduling the script to run every few minutes.

# Again, the name I gave my script was "NoIP"
/system/scheduler/ add name=NoIPCheck interval=3m on-event=NoIP