Community discussions

MikroTik App
 
CoreThread
just joined
Topic Author
Posts: 10
Joined: Thu May 08, 2014 12:40 pm

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

Thu May 08, 2014 1:40 pm

Hi guys!

My script for dynamic IP update for no-ip.info behave weird after update to 6.12 from 5.20. At first I have problem to update IP since he was updating old IP, and now he change IP variable to new IP, but he is updating it every time when script run instead to write to log that no update is needed.

Here is the script:
# No-IP automatic Dynamic DNS update

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

# No-IP User account info
:local noipuser "MY-EMAIL@gmail.com"
:local noippass "MY-PASSWORD"

# 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 "MY-HOSTNAME.noip.me"

# Change to the name of interface that gets the dynamic IP address
:local inetinterface "ADSL" 	#pppoe interface for ISP

#------------------------------------------------------------------------------------
# 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."
}
I only figured out that he is not creating global variable previousIP and if I create it manually he is not updating value...
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12658
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

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

Sat May 10, 2014 5:33 pm

Schedule this at RouterOS boot:
:global previousIP value="0.0.0.0/0";

This is the script fixed for RouterOS 6.12

DO NOT ESCAPE ? WITH ANY.

If you want paste this on terminal, put \ before ?

But this script is intended to be used on scheduled script or terminal?

Obviously on script, then leave ? alone and do not escape anything, 6.x fetch not support escaped characters.

I fix all errors I have noticed, for example declaring LOCAL variables inside cycles, at the end of the cycle the local variables declared INSIDE the cycle are deleted....
:local noipuser value="MY-EMAIL@gmail.com";
:local noippass value="MY-PASSWORD";
:local noiphost value="MY-HOSTNAME.noip.me";
:local inetinterface value="ADSL";
:local currentIP value="0.0.0.0/0";
:local url value="http://dynupdate.no-ip.com/nic/update?myip=";
:if ([/interface get $inetinterface value-name=running] = true) do={
 :set $currentIP value=[/ip address get [find where interface=$inetinterface] address];
 :for i from=([:len $currentIP] - 1) to=0 do={
  :if ([:pick $currentIP $i] = "/") do={ 
   :set $currentIP value=[:pick $currentIP 0 $i];
  } 
 }
 :if ($currentIP != $previousIP) do={
  :log info message=("No-IP: Current IP ".$currentIP." is not equal to previous IP, update needed");
  :set $previousIP value=$currentIP;
  :log info message=("No-IP: Sending update for ".$noiphost);
  /tool fetch url=($url.$currentIP."&hostname=".$noiphost) user=$noipuser password=$noippass mode=http dst-path=("no_ip_ddns_update_".$noiphost.".txt");
  :log info message=("No-IP: Host ".$noiphost." updated on No-IP with IP ".$currentIP);
 } else={
  :log info message=("No-IP: Previous IP ".$previousIP." is equal to current IP, no update needed");
 }
} else={
 :log info message=("No-IP: ".$inetinterface." is not currently running, so therefore will not update.");
}
Last edited by rextended on Tue Jun 03, 2014 3:01 am, edited 2 times in total.
 
CoreThread
just joined
Topic Author
Posts: 10
Joined: Thu May 08, 2014 12:40 pm

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

Sun May 11, 2014 11:18 pm

It doesn't work.
Variable previousIP stay at 0.0.0.0/0 after i run main script and I don't get any message in log...

I edited old script and placed ? instead of 3F but it's the same, it always update my host and doesn't create/change global variable previousIP...
 
CoreThread
just joined
Topic Author
Posts: 10
Joined: Thu May 08, 2014 12:40 pm

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

Sun May 11, 2014 11:20 pm

Double post, sorry about that...
 
CoreThread
just joined
Topic Author
Posts: 10
Joined: Thu May 08, 2014 12:40 pm

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

Tue May 13, 2014 4:12 pm

I don't want to start new topic for this offtopic 'cause it's 6.12 update related and guess someone can give me quick info:
I was changing queues limitations and I notice that my Max Limit for Target Upload (and column Upload Max Limit) is actually my download limit. Same thing for Target Download which is my upload limit.
Is that a 6.12 change/bug or I just forgot that it was the same in 5.20 version???
 
adm1n1strat0r
just joined
Posts: 2
Joined: Tue Jun 10, 2014 11:14 pm

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

Tue Jun 10, 2014 11:29 pm

Hi guys,

I made small corrections in no-ip update script and it's working on RouterOS v6.13.

The changes are:

1) Get value for previous IP address
# Get your previous IP address
   :set previousIP [:resolve $noiphost]

2) Remove creation of no_ip_ddns_update_<no-ip_host>.txt from fetch command with option keep-result=no

Entire code of script:
# 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_no-ip_user"
:local noippass "your_no-ip_pass"

# 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 "hostname.no-ip.net"

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

#------------------------------------------------------------------------------------
# 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]
       } 
   }

# Get your previous IP address
   :set previousIP [:resolve $noiphost]
   
   :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 "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 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."
}


# --------------------------------------------------------------------------------------
 
matteorb
just joined
Posts: 10
Joined: Sat Oct 02, 2010 1:26 am

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

Thu Jun 12, 2014 1:30 pm

Hi Guys,
We need a very big help :D

I Have a RB951G whith routerOS 6.13 - This script doesn't work, i create this file "no-ip_ddns_update" and execute this file with scheduler, but not work.
i attach the script:
# 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 "xxxxxx" <MY USER ID>
:local noippass "xxxxxx" <MY PASSWORD>

# 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 "xxxxxx.noip.me" <MY HOSTNAME>

# Change to the name of interface that gets the dynamic IP address
:local inetinterface "pppoe-out1" <MY NAME OF INTERFACE>

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

#------------------------------------------------------------------------------------
# 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]
       } 
   }

# Get your previous IP address
   :set previousIP [:resolve $noiphost]
   
   :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 "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 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."
}


# --------------------------------------------------------------------------------------
This is the scheduler:
/system scheduler
add comment="Update No-IP DDNS" disabled=yes interval=300s name=no-ip_ddns_update on-event=no-ip_ddns_update policy=read,write,test start-date=jun/12/2014 start-time=08:55:11
Thank's for response!
Greetings
Matteo
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12658
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

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

Thu Jun 12, 2014 1:34 pm

try my script on this topic.
 
matteorb
just joined
Posts: 10
Joined: Sat Oct 02, 2010 1:26 am

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

Thu Jun 12, 2014 3:52 pm

Nothig Rextender, don't work.

i Explain the procedure i did:

1) create the script to run ad all reboot but down work!
http://pichost.me/1839366/

2) Compiled the script with my: email login, password, host and copy the code into /system script
http://pichost.me/1839367/
but when created "if I ever created good", how do I launch this script every 10 or 5 minute used with scheduler???

Sorry but for me it's first time to work with script.
Advice is welcome :lol:

Greetings
Matteo
 
adm1n1strat0r
just joined
Posts: 2
Joined: Tue Jun 10, 2014 11:14 pm

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

Fri Jun 13, 2014 12:34 am

Hi matteorb,

The script in my previous post is working on a same hardware as yours (951G) and on a same OS version (RouterOS 6.13).

I saw that you have option disabled=no in your job scheduler, which means that this job will not be executed. You can use scheduler entry from Wiki page:
/system scheduler add comment="Update No-IP DDNS" disabled=no interval=5m \
name=no-ip_ddns_update on-event=no-ip_ddns_update policy=read,write,test
 
matteorb
just joined
Posts: 10
Joined: Sat Oct 02, 2010 1:26 am

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

Fri Jun 13, 2014 4:23 pm

Hi Guys,
i Resolved the problem with the modify at the script, thanks at the my friend's forum "rodolfo".

Post the working script to insert with scheduler at 5 minute MODIFY ONLY CAPS:
:local noipuser value="INSERT MAIL";
:local noippass value="INSERT PASSWORD";
:local noiphost value="INSERT HOSTNAME";
:local inetinterface value="NAME OF ADSL INTERFACE FOR MY CONNECTION IS PPPOE-OUT1";
:local currentIP value="0.0.0.0/0";
:local url value="http://dynupdate.no-ip.com/nic/update?myip=";
:if ([/interface get NAME OF ADSL INTERFACE value-name=running] = true) do={
 :set $currentIP value=[/ip address get [find where interface=NAME OF ADSL INTERFACE] address];
 :for i from=([:len $currentIP] - 1) to=0 do={
  :if ([:pick $currentIP $i] = "/") do={ 
   :set $currentIP value=[:pick $currentIP 0 $i];
  } 
 }
 :if ($currentIP != $previousIP) do={
  :log info message=("No-IP: Current IP ".$currentIP." is not equal to previous IP, update needed");
  :set $previousIP value=$currentIP;
  :log info message=("No-IP: Sending update for ".$noiphost);
  /tool fetch url=($url.$currentIP."&hostname=".$noiphost) user=$noipuser password=$noippass mode=http dst-path=("no_ip_ddns_update_".$noiphost.".txt");
  :log info message=("No-IP: Host ".$noiphost." updated on No-IP with IP ".$currentIP);
 } else={
  :log info message=("No-IP: Previous IP ".$previousIP." is equal to current IP, no update needed");
 }
} else={
 :log info message=("No-IP: ".NAME OF ADSL INTERFACE." is not currently running, so therefore will not update.");
}

And this is the scheduler script to launch automatically on reboot:
/system scheduler
add name=noip-boot on-event=":global previousIP value=\"0.0.0.0/0\"" policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api start-time=startup
thank's at all for all response.
Greetings
Matteo
 
mgx
just joined
Posts: 4
Joined: Sun Jun 15, 2014 10:41 pm

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

Sun Jun 15, 2014 10:47 pm

no of your scripts has worked for me (as I am behind 2nd NAT), so working modification
#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"

# 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"

# 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 $noiphost]
   
   :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 "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 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."
}


# --------------------------------------------------------------------------------------
 
User avatar
Bigfoot
Frequent Visitor
Frequent Visitor
Posts: 76
Joined: Sat Jan 15, 2011 10:41 am
Location: South Africa

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

Mon Jun 16, 2014 4:35 pm

Thx mgx your script is working for me to. :D
 
mgx
just joined
Posts: 4
Joined: Sun Jun 15, 2014 10:41 pm

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

Mon Jun 16, 2014 6:18 pm

happy to hear that :)
 
jimmyz
Frequent Visitor
Frequent Visitor
Posts: 56
Joined: Wed Jul 02, 2014 10:10 pm

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

Sat Jul 05, 2014 11:32 am

Thx mgx your script is working for me to. :D
Count me in for RB951Ui-2HnD v6.15!
Thank you mgx.
 
jimmyz
Frequent Visitor
Frequent Visitor
Posts: 56
Joined: Wed Jul 02, 2014 10:10 pm

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

Mon Jul 07, 2014 12:19 pm

Tested: also working OK with v.5.26 :D
 
6PATyCb
just joined
Posts: 1
Joined: Thu Jul 24, 2014 9:33 pm

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

Thu Jul 24, 2014 9:45 pm

I think writing file to flash every script run can destroy flash memory very fast.
That my modification of script working with NAT. It can't check prevous ip, update only every run. Writes to flash not needed.
#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 "MY-EMAIL@gmail.com"
:local noippass "MY-PASSWORD"

# 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 "MY-HOSTNAME.noip.me"

# 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={

# 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\3F"
       :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 keep-result=no;
           :log info "No-IP: Host $host updated on No-IP with IP $currentIP"
       }
} else={
   :log info "No-IP: $inetinterface is not currently running, so therefore will not update."
}


# --------------------------------------------------------------------------------------
 
SaeedYa
just joined
Posts: 21
Joined: Fri Jan 14, 2011 9:01 am

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

Thu Dec 11, 2014 9:55 am

no of your scripts has worked for me (as I am behind 2nd NAT), so working modification
#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"

# 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"

# 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 $noiphost]
   
   :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 "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 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."
}


# --------------------------------------------------------------------------------------
Thanks, Working perfectly on 6.23
 
jarda
Forum Guru
Forum Guru
Posts: 7756
Joined: Mon Oct 22, 2012 4:46 pm

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

Fri Dec 12, 2014 6:42 pm

I am using USB flash for such writing operations to preserve internal flash.
 
bluetrepidation
just joined
Posts: 5
Joined: Thu Aug 09, 2012 4:38 am

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

Sun Dec 14, 2014 12:50 am

Hi guys,

I made small corrections in no-ip update script and it's working on RouterOS v6.13.

The changes are:

1) Get value for previous IP address
# Get your previous IP address
   :set previousIP [:resolve $noiphost]

2) Remove creation of no_ip_ddns_update_<no-ip_host>.txt from fetch command with option keep-result=no

Entire code of script:
# 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_no-ip_user"
:local noippass "your_no-ip_pass"

# 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 "hostname.no-ip.net"

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

#------------------------------------------------------------------------------------
# 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]
       } 
   }

# Get your previous IP address
   :set previousIP [:resolve $noiphost]
   
   :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 "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 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."
}


# --------------------------------------------------------------------------------------
Can this change get pushed to the wiki? http://wiki.mikrotik.com/wiki/Dynamic_D ... _No-IP_DNS

Seems outdated,
A.J.
 
piratx
just joined
Posts: 1
Joined: Thu Sep 03, 2015 3:08 am

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

Thu Sep 03, 2015 3:10 am

Thanks a lot, trying and trying for hours but it finally works! :)
 
avggeek
Frequent Visitor
Frequent Visitor
Posts: 60
Joined: Thu Jun 06, 2013 9:33 am

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

Mon Oct 05, 2015 2:43 pm

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."
}
 
AndreasGR
newbie
Posts: 45
Joined: Mon May 14, 2018 5:27 pm

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

Wed May 30, 2018 10:03 am

Unfortunately none of the above seems to be working on 6.42.3.
Has anyone managed to resolve the problem?
Thank you in advance.
 
darvih
just joined
Posts: 7
Joined: Mon Sep 16, 2013 5:30 pm

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

Sat Aug 24, 2019 3:04 pm

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."
}
Last edited by darvih on Sat Aug 24, 2019 10:16 pm, edited 2 times in total.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3349
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

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

Sat Aug 24, 2019 9:21 pm

Edit you post, select your script and click code button </> to get a better formatting on your post.
So it become like this :)