Community discussions

MikroTik App
 
nemke
Member Candidate
Member Candidate
Topic Author
Posts: 160
Joined: Thu Jul 31, 2014 2:52 am

dynDNS SCRIPT THAT WORKS

Wed Feb 10, 2016 2:00 am

Hello
Can someone please post script for dynDNS ip update which work.

I used one but after ROS upgrade to 6.30 ver she stop to work. I try many scripts from forum but no luck, nothing work...

My router is 6.34.1 ver, so some script which work, would be vary helpfull. I need script for double NAT (MT is behind ISP router).

Thank you
 
mpreissner
Member
Member
Posts: 357
Joined: Tue Mar 11, 2014 11:16 pm
Location: Columbia, MD

Re: dynDNS SCRIPT THAT WORKS

Wed Feb 10, 2016 2:16 pm

First, try not to double NAT...always causes problems. Either get rid of the ISP router, or put it in bridge mode. Second...here's my script.
:global ddnsuser "username"
:global ddnspass "password"
:global theinterface "name of external interface, i.e. ether-1-gateway"
:global ddnshost1 your.dyndns.hostname
:global ipddns
:global ipfresh [ /ip address get [/ip address find interface=$theinterface ] address ]
:if ([ :typeof $ipfresh ] = nil ) do={
   :log info ("DynDNS: No ip address on $theinterface .")
} else={
   :for i from=( [:len $ipfresh] - 1) to=0 do={ 
      :if ( [:pick $ipfresh $i] = "/") do={ 
    :set ipfresh [:pick $ipfresh 0 $i];
      } 
}
 
:if ($ipddns != $ipfresh) do={
    :log info ("DynDNS: IP-DynDNS = $ipddns")
    :log info ("DynDNS: IP-Fresh = $ipfresh")
   :log info "DynDNS: Update IP needed, Sending UPDATE...!"
   :global str1 "/nic/update\?hostname=$ddnshost1&myip=$ipfresh&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"
   /tool fetch address=members.dyndns.org src-path=$str1 mode=http user=$ddnsuser password=$ddnspass dst-path=("/DynDNS.".$ddnshost1)
    :delay 1
    :global str1 [/file find name="DynDNS.$ddnshost1"];
    /file remove $str1
    :global ipddns $ipfresh
  :log info "DynDNS: IP updated to $ipfresh!"
    } else={
     :log info "DynDNS: dont need changes";
    }
} 
 
nkourtzis
Member Candidate
Member Candidate
Posts: 214
Joined: Tue Dec 11, 2012 12:56 am
Location: Greece

Re: dynDNS SCRIPT THAT WORKS

Sun Feb 14, 2016 1:58 pm

First, try not to double NAT...always causes problems. Either get rid of the ISP router, or put it in bridge mode.
Or, if you cannot do any of the above, setup the MT router as a DMZ host on the first router. This will *usually* forward all ports of the ISP router to the respective ports of the MT router.
 
User avatar
simobeliata
just joined
Posts: 8
Joined: Tue Feb 09, 2016 10:15 am
Location: Sofia, Bulgaria

Re: dynDNS SCRIPT THAT WORKS

Thu Feb 18, 2016 3:24 pm

If you are behind NAT, that means your WAN interface has PRIVATE IP address. That causes this complicate scripts to not work, because they depend on address, assigned directly to your port.
You need to update your dynamic hostname with your PUBLIC address.
According to DynDNS guide the syntax of the update "command" is as follows:
http://username:password@members.dyndns.org/nic/update?hostname=yourhostname&myip=ipaddress&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG
"myip" is the parameter, which is responsible to provide actual address. The good part is, that if you skip it, the DynDNS server will guess the address, based on request source address. Thus it will assign your PUBLIC address to your host.

In short the request should be:
http://username:password@members.dyndns.org/nic/update?hostname=yourhostname&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG
Here is a short script:
# Define User Variables
:global ddnsuser "DYNDNSUSER"
:global ddnspass "DYNDNSPASS"
:global ddnshost "DYNDNSHOST"

:log info "DynDNS: Sending UPDATE!"
:local str "/nic/update?hostname=$ddnshost&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"
/tool fetch address=members.dyndns.org src-path=$str mode=http user=$ddnsuser password=$ddnspass dst-path=("/DynDNS.".$ddnshost)
 
scampbell
Trainer
Trainer
Posts: 487
Joined: Thu Jun 22, 2006 5:20 am
Location: Wellington, NZ
Contact:

Re: dynDNS SCRIPT THAT WORKS

Thu Feb 18, 2016 9:29 pm

For simple DDNS requirements there is the built in DDNS under /ip cloud ? It's free and it works :-)

It's url is serial_numer.sn.mynetname.net
 
mgx
just joined
Posts: 3
Joined: Sun Jun 15, 2014 10:41 pm

Re: dynDNS SCRIPT THAT WORKS

Wed Feb 24, 2016 10:17 am

 
jo2jo
Forum Guru
Forum Guru
Posts: 1003
Joined: Fri May 26, 2006 1:25 am

Re: dynDNS SCRIPT THAT WORKS

Tue Mar 28, 2017 2:01 am

For simple DDNS requirements there is the built in DDNS under /ip cloud ? It's free and it works :-)

It's url is serial_numer.sn.mynetname.net

Great solution! i had forgot about this feature that MT added a while back! tks
 
th0massin0
Member Candidate
Member Candidate
Posts: 156
Joined: Sun May 11, 2014 4:16 am
Location: Poland

Re: dynDNS SCRIPT THAT WORKS

Tue Mar 28, 2017 3:42 pm

IMHO RouterOS should have native DynDns and NO-IP support. It's not allways possible to get rid of ISP device or use it as a bridge.
 
jarda
Forum Guru
Forum Guru
Posts: 7756
Joined: Mon Oct 22, 2012 4:46 pm

Re: dynDNS SCRIPT THAT WORKS

Tue Mar 28, 2017 3:53 pm

It has ip cloud. You can link whatever your dns to it. If you are a fan of such things... I am against so I am using my own scripts that do not rely on fact whether ip cloud works or not...
 
jo2jo
Forum Guru
Forum Guru
Posts: 1003
Joined: Fri May 26, 2006 1:25 am

Re: dynDNS SCRIPT THAT WORKS

Tue Mar 28, 2017 8:52 pm

IMHO RouterOS should have native DynDns and NO-IP support. It's not allways possible to get rid of ISP device or use it as a bridge.

RouterOS *DOES* already have a solution to this/your issue- (via winbox) its under IP -> CLOUD (enable ddns) or via the CLI: /IP Cloud Print
 
th0massin0
Member Candidate
Member Candidate
Posts: 156
Joined: Sun May 11, 2014 4:16 am
Location: Poland

Re: dynDNS SCRIPT THAT WORKS

Tue Apr 04, 2017 2:16 pm

Could you have a soulution for multi WAN enviorment? Can I choose what WAN interface would be bind to that service?
 
scampbell
Trainer
Trainer
Posts: 487
Joined: Thu Jun 22, 2006 5:20 am
Location: Wellington, NZ
Contact:

Re: dynDNS SCRIPT THAT WORKS

Wed Apr 05, 2017 12:16 am

Could you have a solution for multi WAN enviromment? Can I choose what WAN interface would be bind to that service?
IP Cloud will use the WAN with the smallest distance by default.

If you want to specifically use a different WAN then you would need to use a Mangle Rule on the Output Chain to capture the IP Cloud traffic and give it a route mark that uses the required wan interface.

When enabled '/ip cloud' will send encrypted UDP packets to port 15252 to hosts that resolves from cloud.mikrotik.com.

You could use an address-list entry of cloud.mikrotik.com in a list called Cloud and then

/ip firewall mangle add chain=output protocol=udp dst-port=15252 dst-address-list=Cloud action=mark-routing new-routing-mark=wanx

where "wanx' is a default route using the required wan interface. e.g

/ip route add gateway=pppoe-wan3 routing-mark=wan3
 
camarguesol
just joined
Posts: 5
Joined: Wed Jun 16, 2010 2:01 pm

Re: dynDNS SCRIPT THAT WORKS

Mon Nov 05, 2018 12:45 pm

Thanks "mpreissner",

Script works perfectly on 6.43.4 and Long Term 6.42.9

Lately we have found that the Mikrotik IP Cloud Update returns "updated" and shows correct current IP, but it does not actually update on the Cloud Server.
A ping from the router or any other device returns the old dynamic IP address.

It is a pity the Cloud DDNS has become so flakey. Using the DynDNS service is getting more expensive each year since the Oracle purchase of the company. It appears they are ratcheting up the price until the proverbial "pip's squeak".

It seems that a "NEW" cloud is arriving. viewtopic.php?t=135603
With any luck it will resolve these issues
 
jmerlos282
just joined
Posts: 3
Joined: Wed Nov 14, 2018 1:16 am

Re: dynDNS SCRIPT THAT WORKS

Wed Nov 14, 2018 1:45 am

Thanks, this script works fine for me


If you are behind NAT, that means your WAN interface has PRIVATE IP address. That causes this complicate scripts to not work, because they depend on address, assigned directly to your port.
You need to update your dynamic hostname with your PUBLIC address.
According to DynDNS guide the syntax of the update "command" is as follows:
http://username:password@members.dyndns.org/nic/update?hostname=yourhostname&myip=ipaddress&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG
"myip" is the parameter, which is responsible to provide actual address. The good part is, that if you skip it, the DynDNS server will guess the address, based on request source address. Thus it will assign your PUBLIC address to your host.

In short the request should be:
http://username:password@members.dyndns.org/nic/update?hostname=yourhostname&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG
Here is a short script:
# Define User Variables
:global ddnsuser "DYNDNSUSER"
:global ddnspass "DYNDNSPASS"
:global ddnshost "DYNDNSHOST"

:log info "DynDNS: Sending UPDATE!"
:local str "/nic/update?hostname=$ddnshost&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"
/tool fetch address=members.dyndns.org src-path=$str mode=http user=$ddnsuser password=$ddnspass dst-path=("/DynDNS.".$ddnshost)

Who is online

Users browsing this forum: anton425425, Google [Bot], jacobbailey, Pincha3 and 92 guests