Dynamic DNS Update Script for NO-IP DNS behind NAT

Good morning,
I hope this script will be useful for someone and I want to share it


Create a new script named no-ip_update

The following permissions are required for this script to run:

write
test
read


2. Paste the source code that appears below changing as you need

Set needed variables

:local username “your_no-ip_user”
:local password “your_no-ip_pass”

Set the hostname or label of network to be updated.

:local hostname “hostname.no-ip.info”


/tool fetch mode=http address=“checkip.dyndns.it” src-path=“/” dst-path=“/dyndns.checkip.html”
:local result [/file get dyndns.checkip.html contents]

:global dyndnsForce
:global previousIP

parse the current IP result

:local resultLen [:len $result]
:local startLoc [:find $result “: " -1]
:set startLoc ($startLoc + 2)
:local endLoc [:find $result “” -1]
:local currentIP [:pick $result $startLoc $endLoc]
:log info “UpdateDynDNS: currentIP = $currentIP”;
:if (($currentIP != $previousIP) || ($dyndnsForce = true)) do={
:set dyndnsForce false
:set previousIP $currentIP
/tool fetch mode=http url=“http://$username:$password@dynupdate.no-ip.com/nic/update\3Fhostname=$hostname&myip=$currentIP” dst-path=”/noip.txt"
:local result [/file get noip.txt contents]
:log info (“UpdateDynDNS: Dyndns update needed”)
:log info ("UpdateDynDNS: Dyndns Update Result: ".$result)
:put ("Dyndns Update Result: ".$result)
} else={
:log info (“UpdateDynDNS: No dyndns update needed”)
}


3. then create a new scheduler entry to run this script every 5 mins.

/system scheduler add comment=“Update No-IP DDNS” disabled=no interval=5m
name=no-ip_update on-event=no-ip_update policy=read,write,test


Should it be posted in wiki? How?



ByeBye

Hi vin73,

Thanks for the post, really helpful, as I was trying t do the exact same thing.

One interesting aspect: upon examining the no-ip.com URL “API” (http://www.noip.com/integrate/request) it seems that it’s not really necessary to specific the IP address explicitly, as no-ip.com can query the source of the packet that initiated the HTTP request.

The direct implications for this are:

  1. as long as the default gateway is set to the correct outgoing interface you don’t need to perform IP address discovery on exit interface, you can just query no-ip.com URL without the IP parameter.
  2. NAT’ed setups are not a pain anymore, as the whole system is helping you

Anyway, just my 10c in case anyone has these issues.