I use no-ip.com DDNS service. My script is a modified version of a script I found somewhere on the net.
The primary difference with my scripts is that I have two pppoe-interfaces for different ISP accounts that I switch between as required. The two PPPoE links are never connected at the same time. There is probably a more elegant way to do this, but this script works for my configuration.
Some of my scripts inter-link and reference variables used by other scripts, so if you can’t figure out what some code is for, it’s probably another script or for another config (that will probably be documented somewhere in this category).
This script is scheduled to run every 15 minutes.
# no-ip_ddns_update
### NO-IP Script Settings ###
:local NOIPUser "youruser";
:local NOIPPass "yourpass";
:local NOIPDomain "yourdomain";
#############################
# This script sets currentIP
# This var is used by the unotelly_update script.
:global unotellyUpdateRequired;
:local inetup false;
:local WANInter "";
:local NewIP "";
:if ([/interface get pppoe-out1 value-name=running] && !$inetup) do={
:set WANInter "pppoe-out1";
:set inetup true;
}
:if ([/interface get pppoe-out2 value-name=running] && !$inetup) do={
:set WANInter "pppoe-out2";
:set inetup true;
}
:if ($inetup) do={
:local IpCurrent [/ip address get [find interface=$WANInter] address];
:for i from=( [:len $IpCurrent] - 1) to=0 do={
:if ( [:pick $IpCurrent $i] = "/") do={
:set NewIP [:pick $IpCurrent 0 $i];
:if ([:resolve $NOIPDomain] != $NewIP) do={
/tool fetch mode=http user=$NOIPUser password=$NOIPPass url="http://dynupdate.no-ip.com/nic/update\3Fhostname=$NOIPDomain&myip=$NewIP" keep-result=no;
:log info "NO-IP Update: $NOIPDomain - $NewIP";
# Used by the unotelly_update script
:set unotellyUpdateRequired true;
} else={ :log info "NO-IP Update: $NOIPDomain - No update necessary" }
}
}
} else={ :log info "NO-IP Update: No WAN interfaces are up" }