Page 1 of 1
DDNS Script for No-IP Updated!
Posted: Mon Feb 17, 2014 6:55 pm
by nka
I tried to add the update there, but seems we can't register anymore.
http://wiki.mikrotik.com/wiki/Dynamic_D ... _No-IP_DNS
I fond that the "global" variable wasnt working on the sceduler, so I modified the script to write/read a file instant.
# No-IP automatic Dynamic DNS update
#
#--------------- 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
:local previousIP
if ( [:len [/file find name=("no-ip_ddns_previousip.txt")]] > 0 ) do={
:set previousIP [/file get ("no-ip_ddns_previousip.txt") contents]
}
: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 ($previousIP), update needed"
# 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"
/file print file=("no-ip_ddns_previousip.txt")
:delay 3
/file set contents="$currentIP" ("no-ip_ddns_previousip.txt")
}
} 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."
}
There
![Smile :)](./images/smilies/icon_smile.gif)
Re: DDNS Script for No-IP Updated!
Posted: Thu Feb 27, 2014 4:39 pm
by kei888
Hi!
Is there no need to add scheduler for this new script?
Thanks.
Re: DDNS Script for No-IP Updated!
Posted: Thu Feb 27, 2014 4:41 pm
by kei888
Hi!
No need to add scheduler for this new script?
Thank you.
Re: DDNS Script for No-IP Updated!
Posted: Fri Feb 28, 2014 3:16 pm
by nka
Yes you need. Same as the wiki page (
http://wiki.mikrotik.com/wiki/Dynamic_D ... _No-IP_DNS ). It's just an updated version that write/read a file instant of using global variable that dosent seems to work in 6.7+.
Re: DDNS Script for No-IP Updated!
Posted: Fri Feb 28, 2014 4:58 pm
by kei888
Okay.
Thank you so much.
Re: DDNS Script for No-IP Updated!
Posted: Wed Mar 05, 2014 1:06 pm
by chrisintaipei
i tried it, but it doesn't work for me.
i am on RB2011 v6.7
error code that i am getting:
"No-IP: Current IP (x.x.x.x) is not equal to previous IP(), update needed" -> that's IP(blank)
"No-IP:Sending update for x.myftp.org"
no update at the site.
ran again, identical error, and it is still IP() -> IP(blank).
username and password is correct. i can also see a file been created when click Files.
any idea?
Re: DDNS Script for No-IP Updated!
Posted: Wed Mar 05, 2014 6:16 pm
by nka
Is there something on the file no-ip_ddns_previousip.txt? Should be your IP.
Are you sure email/password are good for no-ip site? Do they have special caractere that the script may not like?
Re: DDNS Script for No-IP Updated!
Posted: Wed Mar 05, 2014 7:22 pm
by chrisintaipei
in the file it says nohost.
then i thought maybe i should manually put 1.1.1.1 in there and see how it works. no luck still.
then i triple checked user/pass are correct.
then i delete the host.txt file. and something interesting happened. it does not create this host txt file any more.
in case i messed it up somewhere, recopy your entire script and entered the variable again, no luck, it still doesn't create the txt file.
i thought maybe reboot would help it. no luck, still not creating that file. free space is 76% so out of space isn't the problem. and the script policy, all 8 are checked.
i was going to create another no-ip account to see maybe my acc is bad, but now it somehow doesn't create that file...
any suggestion?
by the way i got confused, in this place it's RB750, not RB2011 - i doubt that makes any diff though.
Re: DDNS Script for No-IP Updated!
Posted: Wed Mar 05, 2014 7:30 pm
by chrisintaipei
i manually created no-ip_ddns_previousip.txt and put 8.8.8.8 in it. now the log is no longer showing "previous IP ()", but correctly showing "previous IP (8.8.8.
![Cool 8)](./images/smilies/icon_cool.gif)
". however it still doesn't update.
and in addition, when i ran again, the log is showing identical previous IP (8.8.8.
![Cool 8)](./images/smilies/icon_cool.gif)
- that is, it's not writing to the file. but it has all the rights checked....
Re: DDNS Script for No-IP Updated!
Posted: Wed Mar 05, 2014 7:34 pm
by nka
You followed all the informations here :
http://wiki.mikrotik.com/wiki/Dynamic_D ... _No-IP_DNS ?
My scripts it just an update from that (I did not created it).
Check the right for the job too... it's that job who write the file.
My script/schedule have : Read, Write, Test (owner 'admin')
Schedule run at each 5 minutes from the startup.
When you say the file say "nohost", you are talking about the "no-ip_ddns_previousip.txt", not the "no-ip_ddns_update-x.myftp.org.txt" ?
Also, on the log, the "CurrentIP" is good?
You did set the "WAN" interface in the script (mine is "ether1-gateway") ?
Re: DDNS Script for No-IP Updated!
Posted: Wed Mar 05, 2014 7:56 pm
by chrisintaipei
in the file it says nohost.
then i thought maybe i should manually put 1.1.1.1 in there and see how it works. no luck still.
then i triple checked user/pass are correct.
then i delete the host.txt file. and something interesting happened. it does not create this host txt file any more.
actually, the txt file i saw was created by another ddns script. i mistaken it to be yours.
but when i manually created no-ip_ddns_previousip.txt, it then read from it, but does not write into it.
i guess it's rights issue, so i made sure i gave it all the rights (reboot, write, test, sniff, read, policy, password, sensitive), no luck. the owner isn't admin because i renamed it to some other name. but then i created user admin again, and re-login, made sure the script owner is admin (who's group is "full"). but still does not write to the txt.
oh, i didn't wait for the schedule, i clicked run script.
i got a few more mikrotik routers. it's 2am here. as i am out of idea to try, tomorrow i'd try it on other mikrotik routers and see if same works on my other routers but just not this RB750.
any other idea that i can try?
Re: DDNS Script for No-IP Updated!
Posted: Wed Mar 05, 2014 8:00 pm
by nka
remove the files and try to wait for the schedule to see. I think it does not run as the same users.
Also, you are at v6.7 software, did you upgrade the routerboard firmware too ?
Re: DDNS Script for No-IP Updated!
Posted: Thu Mar 06, 2014 8:12 am
by chrisintaipei
interestingly, when i tried it on a different mikrotik router (this is RB751G with v6.6 on it), it worked. it creates two txt files and it updates to no-ip correctly.
then i tried it on a RB2011 with v6.7 on it. it worked too.
all three mikrotik routers are with about the same settings. definitely something must be causing it though. RB751G and RB2011 are with fixed ip, only this problematic RB750 is with dynamic ip. so, well, i know what i am going to be busy with this weekend
many thanks for your great script, and kind help
![Razz :P](./images/smilies/icon_razz.gif)
Re: DDNS Script for No-IP Updated!
Posted: Thu Mar 06, 2014 9:29 pm
by nka
it's good to have moral support !
maybe we should check/change how the check for the IP is made in dynamic IP !
Re: DDNS Script for No-IP Updated!
Posted: Fri Mar 07, 2014 4:13 pm
by kei888
Hi folks!
I'm using RB951G-2HnD with RouterOS 6.9 and 6.10. I tried to use above script but I cannot access my router from the Internet even no-ip was updated with the current Public IP Addresses I got from my ISP.
I was able to verify when I ask my friend to access my router via my no-ip host.
I have this firewall rule during the test:
![Image](http://i57.tinypic.com/2nk4b9y.png)
Re: DDNS Script for No-IP Updated!
Posted: Fri Mar 07, 2014 4:58 pm
by nka
You need to add a Firewall rules:
"input"
"tcp (6)"
"dst port" : Your http/https port.
"allow"
Re: DDNS Script for No-IP Updated!
Posted: Sat Mar 08, 2014 12:09 am
by kei888
I temporarily disabled those firewall rules of mine. I just saw those set of rules upon searching on how to prevent the login attempts I'm seeing before. Those rules really prevented the login attempts via ssh and telnet though I'm not sureif it also affects why my no ip script is now working before, when those rules were still activated.
Does it have an effect why my no ip script is not working?
Thank you.
Re: DDNS Script for No-IP Updated!
Posted: Sat Mar 08, 2014 1:17 am
by kei888
You need to add a Firewall rules:
"input"
"tcp (6)"
"dst port" : Your http/https port.
"allow"
What "http/ https port"? 80 / 443?
Also, i don't see any "allow" option under Action tab, it's accept.
Am I on the right track in executing the said rules?
Re: DDNS Script for No-IP Updated!
Posted: Sat Mar 08, 2014 4:56 am
by nka
yes it's accept, sorry.
http / https is normally set to 80 and 443 if you didnt change it. Mine are changed to 444 or 9443 depending on the application.
Re: DDNS Script for No-IP Updated!
Posted: Sat Mar 08, 2014 6:08 am
by kei888
Okay. I understand now.
With this suggested firewall rule, do I still need to re-enable my firewall rules? Will it not affect my no-ip script and the firewall rule you're suggesting?
Thanks, nka!
Re: DDNS Script for No-IP Updated!
Posted: Sat Mar 08, 2014 6:15 am
by nka
You should have rules enabled yes!
Re: DDNS Script for No-IP Updated!
Posted: Sun Mar 09, 2014 11:56 am
by Yuuki
Hi, I happen to be facing the global variable problem too, your script, does it require some pre-requisite? like creating those files first? and are the firewalls needed for the script to work?
this example in the WIKI doesn't work, I mean it updates well
![Smile :)](./images/smilies/icon_smile.gif)
but it's not checking if the IP has changed or not. which cause it to be sending updates every interval.
http://wiki.mikrotik.com/wiki/Dynamic_D ... _No-IP_DNS
Please advice
![Smile :)](./images/smilies/icon_smile.gif)
thanks!
Re: DDNS Script for No-IP Updated!
Posted: Sun Dec 13, 2015 10:40 pm
by MikroGik
Guys,
It's over a year later, but I thought I'd post my success for others' benefit:
The no-ip script mentioned above works, but only if:
1. in addtion to read/write/test, policy is also checked in the script setup pane (instructions in wiki need updating). If it's not checked, script will look, but will say the current IP doesn't match and needs an update (verified multiple times).
2. Although it works when you log into the no-ip website, the no-ip one-word user ID will not work in the script (at least for me). Make sure you use your email address.
See /Log for an immediate verification if script ran and if it was successful.
Hope this helps,
Gik