Community discussions

MikroTik App
 
nka
newbie
Topic Author
Posts: 44
Joined: Tue Mar 22, 2011 7:48 pm
Location: Quebec, Canada

DDNS Script for No-IP Updated!

Mon Feb 17, 2014 6:55 pm

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 :)
 
kei888
newbie
Posts: 47
Joined: Fri Feb 07, 2014 7:54 am

Re: DDNS Script for No-IP Updated!

Thu Feb 27, 2014 4:39 pm

Hi!

Is there no need to add scheduler for this new script?

Thanks.
 
kei888
newbie
Posts: 47
Joined: Fri Feb 07, 2014 7:54 am

Re: DDNS Script for No-IP Updated!

Thu Feb 27, 2014 4:41 pm

Hi!

No need to add scheduler for this new script?

Thank you.
 
nka
newbie
Topic Author
Posts: 44
Joined: Tue Mar 22, 2011 7:48 pm
Location: Quebec, Canada

Re: DDNS Script for No-IP Updated!

Fri Feb 28, 2014 3:16 pm

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+.
 
kei888
newbie
Posts: 47
Joined: Fri Feb 07, 2014 7:54 am

Re: DDNS Script for No-IP Updated!

Fri Feb 28, 2014 4:58 pm

Okay.

Thank you so much.
 
chrisintaipei
newbie
Posts: 31
Joined: Fri Sep 21, 2012 1:04 pm

Re: DDNS Script for No-IP Updated!

Wed Mar 05, 2014 1:06 pm

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?
 
nka
newbie
Topic Author
Posts: 44
Joined: Tue Mar 22, 2011 7:48 pm
Location: Quebec, Canada

Re: DDNS Script for No-IP Updated!

Wed Mar 05, 2014 6:16 pm

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?
 
chrisintaipei
newbie
Posts: 31
Joined: Fri Sep 21, 2012 1:04 pm

Re: DDNS Script for No-IP Updated!

Wed Mar 05, 2014 7:22 pm

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.
 
chrisintaipei
newbie
Posts: 31
Joined: Fri Sep 21, 2012 1:04 pm

Re: DDNS Script for No-IP Updated!

Wed Mar 05, 2014 7:30 pm

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.8)". however it still doesn't update.

and in addition, when i ran again, the log is showing identical previous IP (8.8.8.8) - that is, it's not writing to the file. but it has all the rights checked....
 
nka
newbie
Topic Author
Posts: 44
Joined: Tue Mar 22, 2011 7:48 pm
Location: Quebec, Canada

Re: DDNS Script for No-IP Updated!

Wed Mar 05, 2014 7:34 pm

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") ?
 
chrisintaipei
newbie
Posts: 31
Joined: Fri Sep 21, 2012 1:04 pm

Re: DDNS Script for No-IP Updated!

Wed Mar 05, 2014 7:56 pm

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?
 
nka
newbie
Topic Author
Posts: 44
Joined: Tue Mar 22, 2011 7:48 pm
Location: Quebec, Canada

Re: DDNS Script for No-IP Updated!

Wed Mar 05, 2014 8:00 pm

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 ?
 
chrisintaipei
newbie
Posts: 31
Joined: Fri Sep 21, 2012 1:04 pm

Re: DDNS Script for No-IP Updated!

Thu Mar 06, 2014 8:12 am

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 :P

many thanks for your great script, and kind help :P
 
nka
newbie
Topic Author
Posts: 44
Joined: Tue Mar 22, 2011 7:48 pm
Location: Quebec, Canada

Re: DDNS Script for No-IP Updated!

Thu Mar 06, 2014 9:29 pm

it's good to have moral support !

maybe we should check/change how the check for the IP is made in dynamic IP !
 
kei888
newbie
Posts: 47
Joined: Fri Feb 07, 2014 7:54 am

Re: DDNS Script for No-IP Updated!

Fri Mar 07, 2014 4:13 pm

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
 
nka
newbie
Topic Author
Posts: 44
Joined: Tue Mar 22, 2011 7:48 pm
Location: Quebec, Canada

Re: DDNS Script for No-IP Updated!

Fri Mar 07, 2014 4:58 pm

You need to add a Firewall rules:

"input"
"tcp (6)"
"dst port" : Your http/https port.
"allow"
 
kei888
newbie
Posts: 47
Joined: Fri Feb 07, 2014 7:54 am

Re: DDNS Script for No-IP Updated!

Sat Mar 08, 2014 12:09 am

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.
 
kei888
newbie
Posts: 47
Joined: Fri Feb 07, 2014 7:54 am

Re: DDNS Script for No-IP Updated!

Sat Mar 08, 2014 1:17 am

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?
 
nka
newbie
Topic Author
Posts: 44
Joined: Tue Mar 22, 2011 7:48 pm
Location: Quebec, Canada

Re: DDNS Script for No-IP Updated!

Sat Mar 08, 2014 4:56 am

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.
 
kei888
newbie
Posts: 47
Joined: Fri Feb 07, 2014 7:54 am

Re: DDNS Script for No-IP Updated!

Sat Mar 08, 2014 6:08 am

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!
 
nka
newbie
Topic Author
Posts: 44
Joined: Tue Mar 22, 2011 7:48 pm
Location: Quebec, Canada

Re: DDNS Script for No-IP Updated!

Sat Mar 08, 2014 6:15 am

You should have rules enabled yes!
 
Yuuki
just joined
Posts: 11
Joined: Fri Jan 17, 2014 3:12 pm

Re: DDNS Script for No-IP Updated!

Sun Mar 09, 2014 11:56 am

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 :) 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 :) thanks!
 
MikroGik
just joined
Posts: 15
Joined: Tue Dec 23, 2014 3:23 am

Re: DDNS Script for No-IP Updated!

Sun Dec 13, 2015 10:40 pm

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

Who is online

Users browsing this forum: Bing [Bot] and 8 guests