Page 1 of 1
Problem with script for no-ip.info after update to 6.12
Posted: Thu May 08, 2014 1:40 pm
by CoreThread
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...
Re: Problem with script for no-ip.info after update to 6.12
Posted: Sat May 10, 2014 5:33 pm
by rextended
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.");
}
Re: Problem with script for no-ip.info after update to 6.12
Posted: Sun May 11, 2014 11:18 pm
by CoreThread
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...
Re: Problem with script for no-ip.info after update to 6.12
Posted: Sun May 11, 2014 11:20 pm
by CoreThread
Double post, sorry about that...
Re: Problem with script for no-ip.info after update to 6.12
Posted: Tue May 13, 2014 4:12 pm
by CoreThread
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???
Re: Problem with script for no-ip.info after update to 6.12
Posted: Tue Jun 10, 2014 11:29 pm
by adm1n1strat0r
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."
}
# --------------------------------------------------------------------------------------
Re: Problem with script for no-ip.info after update to 6.12
Posted: Thu Jun 12, 2014 1:30 pm
by matteorb
Hi Guys,
We need a very big help
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
Re: Problem with script for no-ip.info after update to 6.12
Posted: Thu Jun 12, 2014 1:34 pm
by rextended
try my script on this topic.
Re: Problem with script for no-ip.info after update to 6.12
Posted: Thu Jun 12, 2014 3:52 pm
by matteorb
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
Greetings
Matteo
Re: Problem with script for no-ip.info after update to 6.12
Posted: Fri Jun 13, 2014 12:34 am
by adm1n1strat0r
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
Re: Problem with script for no-ip.info after update to 6.12
Posted: Fri Jun 13, 2014 4:23 pm
by matteorb
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
Re: Problem with script for no-ip.info after update to 6.12
Posted: Sun Jun 15, 2014 10:47 pm
by mgx
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."
}
# --------------------------------------------------------------------------------------
Re: Problem with script for no-ip.info after update to 6.12
Posted: Mon Jun 16, 2014 4:35 pm
by Bigfoot
Thx mgx your script is working for me to.
![Very Happy :D](./images/smilies/icon_biggrin.gif)
Re: Problem with script for no-ip.info after update to 6.12
Posted: Mon Jun 16, 2014 6:18 pm
by mgx
happy to hear that
![Smile :)](./images/smilies/icon_smile.gif)
Re: Problem with script for no-ip.info after update to 6.12
Posted: Sat Jul 05, 2014 11:32 am
by jimmyz
Thx mgx your script is working for me to.
![Very Happy :D](./images/smilies/icon_biggrin.gif)
Count me in for RB951Ui-2HnD v6.15!
Thank you mgx.
Re: Problem with script for no-ip.info after update to 6.12
Posted: Mon Jul 07, 2014 12:19 pm
by jimmyz
Tested: also working OK with v.5.26
![Very Happy :D](./images/smilies/icon_biggrin.gif)
Re: Problem with script for no-ip.info after update to 6.12
Posted: Thu Jul 24, 2014 9:45 pm
by 6PATyCb
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."
}
# --------------------------------------------------------------------------------------
Re: Problem with script for no-ip.info after update to 6.12
Posted: Thu Dec 11, 2014 9:55 am
by SaeedYa
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
Re: Problem with script for no-ip.info after update to 6.12
Posted: Fri Dec 12, 2014 6:42 pm
by jarda
I am using USB flash for such writing operations to preserve internal flash.
Re: Problem with script for no-ip.info after update to 6.12
Posted: Sun Dec 14, 2014 12:50 am
by bluetrepidation
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.
Re: Problem with script for no-ip.info after update to 6.12
Posted: Thu Sep 03, 2015 3:10 am
by piratx
Thanks a lot, trying and trying for hours but it finally works!
![Smile :)](./images/smilies/icon_smile.gif)
Re: Problem with script for no-ip.info after update to 6.12
Posted: Mon Oct 05, 2015 2:43 pm
by avggeek
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."
}
Re: Problem with script for no-ip.info after update to 6.12
Posted: Wed May 30, 2018 10:03 am
by AndreasGR
Unfortunately none of the above seems to be working on 6.42.3.
Has anyone managed to resolve the problem?
Thank you in advance.
Re: Problem with script for no-ip.info after update to 6.12
Posted: Sat Aug 24, 2019 3:04 pm
by darvih
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."
}
Re: Problem with script for no-ip.info after update to 6.12
Posted: Sat Aug 24, 2019 9:21 pm
by Jotne
Edit you post, select your script and click code button
</> to get a better formatting on your post.
So it become like this :)