Problem with script for no-ip.info after update to 6.12

Thanks a lot, trying and trying for hours but it finally works! :slight_smile:

Hello - I tried mgx’s script and found that there was a problem if you were trying to update the IP for more than one hostname at a time using this script.

I eventually traced the problem to line #51, where the script gets the previous IP for the hostname. This part of the script does not support multiple hostnames but the actual IP updation process does. As a quick workaround, I added another variable which is for a single hostname only and did the previous IP check using this new variable.

I also made one more change which is to use a HTTPS connection when calling the no-ip page, which is a better option when using HTTP basic auth.

This is tested to be working on ROS 6.30.1

#No-IP automatic Dynamic DNS update for RouterOS v6.x

#--------------- Change Values in this section to match your setup ------------------

# No-IP User account info
:local noipuser "YOUR_LOGIN_TO_NO_IP"
:local noippass "YOUR_PASSWORD_TO NO_IP"

# Workaround - find IP of a single dynamic host for IP prior to update
# Only enter a single hostname for this variable
:local previphost "YOUR_HOST.no-ip.org"

# Set the hostname or label of network to be updated.
# Hostnames with spaces are unsupported. Replace the value in the quotations below with your host names.
# To specify multiple hosts, separate them with commas.
:local noiphost "YOUR_HOST.no-ip.org,YOUR_HOST.no-ip.com"

# Change to the name of interface that gets the dynamic IP address
:local inetinterface "YOUR_WAN_INTERFACE_NAME_f.e_port2_public"

#------------------------------------------------------------------------------------
# No more changes need

:global previousIP

:if ([/interface get $inetinterface value-name=running]) do={

# get the current IP address from the internet (in case of double-nat)
/tool fetch mode=http address="checkip.dyndns.org" src-path="/" dst-path="dyndns.checkip.html"
:local result [/file get dyndns.checkip.html contents]

# 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 "Update NO-IP.com: currentIP = $currentIP"

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

# Get your previous IP address
   :set previousIP [:resolve $previphost]
   
   :if ($currentIP != $previousIP) do={
       :log info "No-IP: Current IP $currentIP is not equal to previous IP $previousIP, update needed"
       :set previousIP $currentIP

# The update URL. Note the "\3F" is hex for question mark (?). Required since ? is a special character in commands.
       :local url "https://dynupdate.no-ip.com/nic/update\3Fmyip=$currentIP"
       :local noiphostarray
       :set noiphostarray [:toarray $noiphost]
       :foreach host in=$noiphostarray do={
           :log info "No-IP: Sending update for $host"
           /tool fetch url=($url . "&hostname=$host") user=$noipuser password=$noippass mode=https keep-result=no;
           :log info "No-IP: Host $host updated on No-IP with IP $currentIP"
       }
   }  else={
       :log info "No-IP: Previous IP $previousIP is equal to current IP, no update needed"
   }
} else={
   :log info "No-IP: $inetinterface is not currently running, so therefore will not update."
}

Unfortunately none of the above seems to be working on 6.42.3.
Has anyone managed to resolve the problem?
Thank you in advance.

thank u
work on 6.45.3
note : don’t have β€œ-” interface name.

# No-IP automatic Dynamic DNS update

#--------------- Change Values in this section to match your setup ------------------

# No-IP User account info
:local noipuser "*******"
:local noippass "******"

# Set the hostname or label of network to be updated.
# Hostnames with spaces are unsupported. Replace the value in the quotations below with your host names.
# To specify multiple hosts, separate them with commas.
:local noiphost "irvpnmeshki.ddns.net"

# Change to the name of interface that gets the dynamic IP address
:local inetinterface "pppoe"
# No more changes need

:global previousIP

:if ([/interface get $inetinterface value-name=running]) do={
# Get the current IP on the interface
   :local currentIP [/ip address get [find interface="$inetinterface" 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 ($currentIP != $previousIP) do={
       :log info "No-IP: Current IP $currentIP is not equal to previous IP, update needed"
       :set previousIP $currentIP

# The update URL. Note the "\3F" is hex for question mark (?). Required since ? is a special character in commands.
       :local url "http://dynupdate.no-ip.com/nic/update\3Fmyip=$currentIP"
       :local noiphostarray
       :set noiphostarray [:toarray $noiphost]
       :foreach host in=$noiphostarray do={
           :log info "No-IP: Sending update for $host"
           /tool fetch url=($url . "&hostname=$host") user=$noipuser password=$noippass mode=http dst-path=("no_ip_ddns_update_" . $host . ".txt")
           :log info "No-IP: Host $host updated on No-IP with IP $currentIP"
       }
   }  else={
       :log info "No-IP: Previous IP $previousIP is equal to current IP, no update needed"
   }
} else={
   :log info "No-IP: $inetinterface is not currently running, so therefore will not update."
}

Edit you post, select your script and click code button </> to get a better formatting on your post.

So it become like this :)