Hi all!
I drew on a number of scripts to develop a version that is simple and suitable for multiple internet lines (up to 3 here). Basically, what it does is that it compares the local IP address of each PPPoE interface to the corresponding IP address returned by the DNS server and, when the two do not match, it sends an update to DynDNS and to the log. The log is also informed upon failure to obtain the local IP address. As the script is not resource-intensive, it should be able to run every minute without problems.
# REQUIRES DNS TO BE SET UP ON MIKROTIK
:local dnHost1 "~~~~~e.g._no1_host.dyndns.org~~~~~"
:local dnHost2 "~~~~~e.g._no2_host.dyndns.org~~~~~"
:local dnHost3 0
:local inFace1 "~~~~~e.g._no1_pppoe_interface_name~~~~~"
:local inFace2 "~~~~~e.g._no2_pppoe_interface_name~~~~~"
:local inFace3 0
# UP TO 3 DYNDNS HOST / INTERFACE COMBINATIONS CAN BE INSERTED ABOVE
:local dnsPass "~~~~~e.g._my_password~~~~~"
:local dnsUser "~~~~~e.g._my_username~~~~~"
# ALL PRECEDING ENTRIES MUST BE REPLACED BY ACTUAL DATA INSIDE DOUBLE QUOTES OR ZEROS
:local aa
:local dnHosts [:toarray ($dnHost1,$dnHost2,$dnHost3)]
:local inFaces [:toarray ($inFace1,$inFace2,$inFace3)]
:local ipNowIs
:for pp from=0 to=2 do={
:set dnHost1 [:pick $dnHosts $pp]
:set inFace1 [:pick $inFaces $pp]
:if ( ($dnHost1!=0) && ($inFace1!=0) ) do={
:set aa [/ip address get [find interface=$inFace1] address]
:set ipNowIs [:toip [:pick $aa 0 [:find $aa "/"]]]
:if ( [:typeof $ipNowIs]!="ip" ) do={
:log info "••• $inFace1: Failed to get local IP address."
} else={
:if ( [:resolve $dnHost1]!=$ipNowIs ) do={
:set aa "/nic/update?backmx=NOCHG&hostname=$dnHost1&mx=NOCHG&myip=$ipNowIs&wildcard=NOCHG"
/tool fetch address=members.dyndns.org dst-path=/dyndns.html mode=http password=$dnsPass src-path=$aa user=$dnsUser
:delay 99ms
/file remove dyndns.html
:log info "••• $inFace1: DynDNS address updated to $ipNowIs."
} } } }
I hope that others find this script helpful. All comments and ideas for improvement are most welcome.