Community discussions

MikroTik App
 
Shlyahov
just joined
Topic Author
Posts: 1
Joined: Sun Apr 02, 2017 9:01 pm

No-IP & DNSdynamic update

Mon Apr 03, 2017 7:19 pm

Exellent working script for update DDNS of NO-IP in conjunction with DNSdynamic Sevices.
Debugging and checking done.
Made because of the unreliability of long-term work without confirmation on NO-IP service.



I am sorry for my bad english
# No-IP, DNSdynamic update

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

#User account info
:local noipuser "NO-IP_User_Name"
:local noippass "NO-IP_password"
:local dnsdynamicuser "DNSdynamic_User_Name"
:local dnsdynamicpass "DNSdynamic_password"
:local noiphost "NO-IP_host"
:local dnsdynamichost "DNSdynamic_host"

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

#-------------------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 "IP: Current IP $currentIP is not equal to previous IP, update needed"
       :set previousIP $currentIP

# The update No-Ip 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"
       }

# The update dnsdynamic URL. Note the "\3F" is hex for question mark (?). Required since ? is a special character in commands.
       :local url "https://www.dnsdynamic.org/nic/nic/update\3Fmyip=$currentIP"
       :local dnsdynamichostarray
       :set dnsdynamichostarray [:toarray $dnsdynamichost]
       :foreach host in=$dnsdynamichostarray do={
           :log info "dnsdynamic: Sending update for $host"
           /tool fetch url=($url . "&hostname=$host") user=$dnsdynamicuser password=$dnsdynamicpass mode=http dst-path=("dnsdynamic_ddns_update-" . $host . ".txt")
           :log info "dnsdynamic: Host $host updated on dnsdynamic with IP $currentIP"
       }
   }  else={
       :log info "IP: Previous IP $previousIP is equal to current IP, no update needed"
   }
} else={
   :log info "IP: $inetinterface is not currently running, so therefore will not update."
}
 
Rey46
newbie
Posts: 25
Joined: Sat Aug 06, 2016 5:00 pm

Re: No-IP & DNSdynamic update

Tue Apr 04, 2017 3:21 pm

Hi Shlyahov,
I use this script found on this forum, it works with no-ip and it doesn't require an interface so you can use with failover ;) Hope it is usefull for you and others people.
# Atualização automática de DNS Dinâmico NO-IP

#--------------- Defina os valores nessa sessão para configurar ------------------

# Informações de acesso NO-IP
:local noipuser "EMAIL OU NOME DE LOGIN DO NOIP"
:local noippass "SENHA DE LOGIN"

# Defina o nome do servidor da web a ter o IP atualizado.
# O nome do servidor não aceita espaços. Substitua o valor entre as aspas pelo nome(URL) do seu servidor.
# Para especificar vários servidores, separe-os com vírgulas.
:local noiphost "HOST, EX.: host.ddns.net"


#------------------------------------------------------------------------------------
# Não precisa alterar mais nada

:global previousIP

/tool fetch url="http://myip.dnsomatic.com/" mode=http dst-path=mypublicip.txt
:local currentIP [file get mypublicip.txt contents]

# 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: O ip atual $currentIP não é igual ao IP anterior, atualização necessária"
       :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: Servidor $host atualizado com o IP $currentIP"
       }
   }  else={
       :log info "No-IP: IP anterior $previousIP é igual o IP atual, atualização não necessária."
   }
 
qbek
just joined
Posts: 20
Joined: Mon Sep 21, 2015 3:34 pm
Location: Poland
Contact:

Re: No-IP & DNSdynamic update

Sat Apr 08, 2017 1:33 pm

Non of them are working for me. I have to login at noip.com and manually change ip given from RB log and hit Update hostname.
 
Rey46
newbie
Posts: 25
Joined: Sat Aug 06, 2016 5:00 pm

Re: No-IP & DNSdynamic update

Mon Apr 10, 2017 4:10 pm

Non of them are working for me. I have to login at noip.com and manually change ip given from RB log and hit Update hostname.
Which errors?
 
qbek
just joined
Posts: 20
Joined: Mon Sep 21, 2015 3:34 pm
Location: Poland
Contact:

Re: No-IP & DNSdynamic update

Mon Apr 10, 2017 11:17 pm

Log
06:12:13 system,info router rebooted
06:12:20 pppoe,ppp,info pppoe-out1_VDSL: initializing...
06:12:20 pppoe,ppp,info pppoe-out1_VDSL: connecting...
06:12:21 interface,info ether5 link up (speed 100M, full duplex)
06:12:23 interface,info ether4 link up (speed 100M, full duplex)
06:12:25 pppoe,ppp,info pppoe-out1_VDSL: authenticated
06:12:25 pppoe,ppp,info pppoe-out1_VDSL: connected
06:12:25 system,info item added
06:12:25 system,info item added
06:15:37 script,info IP: Current IP 83.x.x.x is not equal to previous IP, update needed
06:15:37 script,info No-IP: Sending update for domain.ddns.net
06:47:17 script,info IP: Current IP 83.x.x.x is not equal to previous IP, update needed
06:47:17 script,info No-IP: Sending update for domain.ddns.net

here I delete file no-ip_ddns_update-domain.ddns.net.txt from "Files"
Fetch file contain nochg IP.

08:02:40 script,info IP: Current IP 83.x.x.x is not equal to previous IP, update needed
08:02:40 script,info No-IP: Sending update for domain.ddns.net
08:02:40 info fetch: file "no-ip_ddns_update-domain.ddns.net.txt" downloaded
08:02:41 script,info No-IP: Host domain.ddns.net updated on No-IP with IP 83.x.x.x
08:02:41 script,info dnsdynamic: Sending update for DNSdynamic_host
08:32:16 script,info IP: Current IP 83.x.x.x is not equal to previous IP, update needed
08:32:16 script,info No-IP: Sending update for domain.ddns.net
09:07:16 script,info IP: Current IP 83.x.x.x is not equal to previous IP, update needed
09:07:16 script,info No-IP: Sending update for domain.ddns.net

Scheduler:
name="no-ip" start-time=startup interval=35m on-event=/system script run no-ip owner="kuba" policy=ftp,read,write,test run-count=27 next-run=22:32:16

FAQ noip:
nochg IP_ADDRESS Success IP address is current, no update performed. Followed by a space and the IP address that it is currently set to.

Support from noip said "After reviewing our logs for this hostname I am seeing the result "badauth". It looks like the username or password inputted into the DDNS settings are wrong. It could also be that you have a special characters, like %&#...? This could cause issues, too. "
I have checked twice login and pass in script and is OK.
I disabled IP-->Cloud.
 
qbek
just joined
Posts: 20
Joined: Mon Sep 21, 2015 3:34 pm
Location: Poland
Contact:

Re: No-IP & DNSdynamic update

Sun Apr 16, 2017 4:06 pm

Noip support ask me to use this script.
Why I'm not getting fetch txt file now?
Can somebody test it on v6.39rc58 and newest firmware for motherboard 3.33?


# No-IP automatic Dynamic DNS update
#--------------- Change Values in this section to match your setup ------------------
# No-IP User account info
:local noipuser "your@email.com"
:local noippass "yourpassword"
# 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 "yourname.ddns.net"
# Change to the name of interface that gets the dynamic IP address
:local inetinterface "yourinterface"
#------------------------------------------------------------------------------------
# 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];
}
}
:local previousIP [:resolve "$noiphost"];
:log info "DNS IP: $previousIP, interface IP: $currentIP";
:if ($currentIP != $previousIP) do={
:log info "No-IP: Current IP $currentIP is not equal to previous IP $previousIP, update needed";
# :set previousIP $currentIP;
:local url "http://dynupdate.no-ip.com/nic/update\3Fmyip=$currentIP";
:log info "No-IP: Sending update for $noiphost";
/tool fetch url=($url . "&hostname=$noiphost") user=$noipuser password=$noippass mode=http dst-path=("no-ip_ddns_update-" . $host . ".txt")
:log info "No-IP: Host $noiphost 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
ahmedalmi
Frequent Visitor
Frequent Visitor
Posts: 75
Joined: Sat Sep 13, 2014 5:52 pm
Location: sana'a yemen
Contact:

Re: No-IP & DNSdynamic update

Sun May 14, 2017 4:17 am

enable cloud DDNS
or use this

Code: Select all

/ip cloud set ddns-enabled=yes
then try to use this

Code: Select all

{
:local noipuser "your@email.com"
:local noippass "yourpassword"

:local noiphost "yourname.ddns.net"
:local inetinterface "yourinterface"

:global previousIP;

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

:local currentIP [/ip cloud get public-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


: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."
}
}
 
qbek
just joined
Posts: 20
Joined: Mon Sep 21, 2015 3:34 pm
Location: Poland
Contact:

Re: No-IP & DNSdynamic update

Mon May 15, 2017 10:38 am

Thanks but I'm using now freedns.afraid.org
 
User avatar
saintofinternet
Forum Veteran
Forum Veteran
Posts: 768
Joined: Thu Oct 15, 2009 3:52 am

Re: No-IP & DNSdynamic update

Mon Jun 05, 2017 7:44 pm

ver 6.38.3 has none of the scripts working for No-IP....

can someone help please?
 
sam2030
just joined
Posts: 1
Joined: Thu Dec 21, 2017 9:50 pm

Re: No-IP & DNSdynamic update

Thu Dec 21, 2017 9:53 pm

 
User avatar
saintofinternet
Forum Veteran
Forum Veteran
Posts: 768
Joined: Thu Oct 15, 2009 3:52 am

Re: No-IP & DNSdynamic update

Fri Dec 22, 2017 4:01 am

that was the same one i was using before the routeros upgraded.

after the upgrade it stopped working.
 
User avatar
ErfanDL
Member
Member
Posts: 366
Joined: Thu Sep 29, 2016 9:13 am

Re: No-IP & DNSdynamic update

Fri Dec 22, 2017 9:09 am

that was the same one i was using before the routeros upgraded.

after the upgrade it stopped working.
Hi try this script
its working on 6.40.x and 6.41.x RC
# No-IP automatic Dynamic DNS update

:local noipuser "username"
:local noippass "password"
:local noiphost "hostname-kamu.ddns.net"
:local inetinterface "ether-inet"

:global currentIP
:global previousIP

:if ([/interface get $inetinterface value-name=running]) do={
 :local currentIP [/ip address get [find interface="$inetinterface" disabled=no] 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 Updater: Current IP address $currentIP is not equal to previous IP, update needed"
 :set previousIP $currentIP

: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 Updater: 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 Updater: Update change requested. Hostname $host will be updated with $currentIP"
 }
 } else={
 :log info "No-IP Updater: Previous IP address $previousIP is equal to current IP, no update needed"
 }
} else={
 :log info "No-IP Updater: $inetinterface is not currently running, so therefore will not update"
}
 
linhchivas
just joined
Posts: 2
Joined: Fri Dec 29, 2017 1:03 pm

Re: No-IP & DNSdynamic update

Fri Dec 29, 2017 1:07 pm

i have problem with version 6.36.in log,it write : "No-IP Updater: Previous IP address 42.x.x.x is equal to current IP, no update needed".But i check at noip,ip dont update anything.Please help me
 
ortegaav
just joined
Posts: 1
Joined: Wed Nov 18, 2020 1:35 pm

Re: No-IP & DNSdynamic update

Wed Nov 18, 2020 1:55 pm

This is a new script, which is running in versión 6.46.8
**************************************************************

System/Script/Add

Name:"Update_NOIP" or anyone you want

Policy: check
-Don´t Require Permissions
-read
-write
-test

***************************************************************
##############Script Settings##################

:local NOIPUser "your_no-ip_user"
:local NOIPPass "your_no-ip_pass"
:local WANInter "your_external_interface"
:local NOIPDomain "hostname.no-ip.net"

###############################################

# Get the current IP on the interface
:local currentIP [/ip address get [find interface="$WANInter" 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 ([:resolve $NOIPDomain] != $currentIP) do={
      /tool fetch mode=http user=$NOIPUser password=$NOIPPass url="http://dynupdate.no-ip.com/nic/update\3Fhostname=$NOIPDomain&myip=$currentIP" keep-result=no
      :log info "NO-IP Update: $NOIPDomain - $currentIP"
}

***************************************************************

System/Scheduler/Add

Name: Any you want
Start Date: "Oct/30/2020" for example
Start Time: "00:00:00" for example
Interval:"00:00:10" or anyone you want
Policy: check
-read
-write
-test
On Event:"Update_NOIP" or the name you put the script

***************************************************************
Last edited by ortegaav on Wed Nov 18, 2020 2:02 pm, edited 1 time in total.
 
leduycuong12345
just joined
Posts: 2
Joined: Fri Sep 22, 2023 7:00 am

Re: No-IP & DNSdynamic update

Sat Sep 30, 2023 9:30 am

ortegaav's asnwer still works like a charm. Tested by routerboard rb750gr3 version 6.49.7 . Tks u guys.
 
pockybum522
just joined
Posts: 1
Joined: Tue Jan 16, 2024 7:43 pm

Re: No-IP & DNSdynamic update

Tue Jan 16, 2024 9:59 pm

Worked great for me also on RB4011iGS+ with RouterOS 7.13.1, thank you.
 
spamdog
just joined
Posts: 3
Joined: Wed Oct 26, 2016 2:10 pm

Re: No-IP & DNSdynamic update

Thu Feb 08, 2024 6:11 pm

Since december 2023 this script not works for me. Device: RB4011iGS+5HacQ2HnD
But from v7.13.4 I've got a log line:
mtikscripterror.jpg
The Script settings are:
mtikscripterror1.jpg
You do not have the required permissions to view the files attached to this post.
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3255
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: No-IP & DNSdynamic update

Thu Feb 08, 2024 6:46 pm

Might try adding "ftp" policy.
 
spamdog
just joined
Posts: 3
Joined: Wed Oct 26, 2016 2:10 pm

Re: No-IP & DNSdynamic update

Fri Feb 23, 2024 12:17 pm

Amm0 Thank you it works. (But why ftp the name of this right?)

Who is online

Users browsing this forum: No registered users and 10 guests