dynamic dns script mikrotik dynamic dns script mikrot...

Topic: dynamic dns script mikrotik

Post dynamic dns script mikrotik
by shady shata on Monday, August 17, 2015

dynamic dns script mikrotik
http://wiki.mikrotik.com/wiki/Dynamic_DNS_Update_Script_for_dynDNS
Is there a possibility to include the Account on my device like that mikrotik
----------
# Define User Variables
:global ddnsuser "DYNDNSUSER"
:global ddnspass "DYNDNSPASS"
:global ddnshost "DYNDNSHOST"

# Define Global Variables
:global ddnsip
:global ddnslastip
:if ([ :typeof $ddnslastip ] = nil ) do={ :global ddnslastip "0" }

:global ddnsinterface
:global ddnssystem ("mt-" . [/system package get system version] )

# Define Local Variables
:local int

# Loop thru interfaces and look for ones containing
# default gateways without routing-marks
:foreach int in=[/ip route find dst-address=0.0.0.0/0 active=yes ] do={
:if ([:typeof [/ip route get $int routing-mark ]] != str ) do={
:global ddnsinterface [/ip route get $int interface]
}
}

# Grab the current IP address on that interface.
:global ddnsip [ /ip address get [/ip address find interface=$ddnsinterface ] address ]

# Did we get an IP address to compare?
:if ([ :typeof $ddnsip ] = nil ) do={
:log info ("DynDNS: No ip address present on " . $ddnsinterface . ", please check.")
} else={
:if ($ddnsip != $ddnslastip) do={
:log info "DynDNS: Sending UPDATE!"
:local str "/nic/update?hostname=$ddnshost&myip=$ddnsip&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)
:delay 1
:local str [/file find name="DynDNS.$ddnshost"];
/file remove $str
:global ddnslastip $ddnsip
}
}

Reply with quote | Report
Post Re: dynamic dns script mikrotik
by timothytw on Tuesday, August 18, 2015

Our dynamic DNS service can be used on Mikrotik devices. Please try the following script:

----------
# Define User Variables
:global ddnsuser "YourDynuUsername"
:global ddnspass "YourDynuPassword"
:global ddnshost "YourDynuHostname"

# Define Global Variables
:global ddnsip
:global ddnslastip
:if ([ :typeof $ddnslastip ] = nil ) do={ :global ddnslastip "0" }

:global ddnsinterface
:global ddnssystem ("mt-" . [/system package get system version] )

# Define Local Variables
:local int

# Loop thru interfaces and look for ones containing
# default gateways without routing-marks
:foreach int in=[/ip route find dst-address=0.0.0.0/0 active=yes ] do={
:if ([:typeof [/ip route get $int routing-mark ]] != str ) do={
:global ddnsinterface [/ip route get $int interface]
}
}

# Grab the current IP address on that interface.
:global ddnsip [ /ip address get [/ip address find interface=$ddnsinterface ] address ]

# Did we get an IP address to compare?
:if ([ :typeof $ddnsip ] = nil ) do={
:log info ("Dynu: No ip address present on " . $ddnsinterface . ", please check.")
} else={
:if ($ddnsip != $ddnslastip) do={
:log info "Dynu: Sending UPDATE!"
:local str
"/nic/update?hostname=$ddnshost&myip=$ddnsip"
/tool fetch address=api.dynu.com src-path=$str mode=http user=$ddnsuser \
password=$ddnspass dst-path=("/Dynu.".$ddnshost)
:delay 1
:local str [/file find name="Dynu.$ddnshost"];
/file remove $str
:global ddnslastip $ddnsip
}
}

Please change the values in bold with your Dynu account details. Please note that your username can be found in 'Contact Details' section in Dynu control panel.

For more information, you may refer to our IP update protocol at https://www.dynu.com/Resources/API

Reply with quote | Report
Post Re: dynamic dns script mikrotik
by shadysoft on Tuesday, August 18, 2015

:global ddnsuser "userdynu"
:global ddnspass "passdynu"
:global theinterface "lan name"
:global ddnshost "hostname"
:global ipddns [:resolve $ddnshost];
:global ipfresh [ /ip address get [/ip address find interface=$theinterface ] address ]
:if ([ :typeof $ipfresh ] = nil ) do={
:log info ("dynu: 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 ("dynu: IP-dynu = $ipddns")
:log info ("dynu: IP-Fresh = $ipfresh")
:log info "dynu: Update IP needed, Sending UPDATE...!"
:global str "/nic/update?hostname=$ddnshost&myip=$ipfresh"
/tool fetch address=api.dynu.com src-path=$str mode=http user=$ddnsuser password=$ddnspass dst-path=("/Dynu.".$ddnshost)
:delay 1
:global str [/file find name="Dynu.$ddnshost"];
/file remove $str
:global ipddns $ipfresh
:log info "dynu: IP updated to $ipfresh!"
} else={
:log info "dynu: dont need changes";
}
}
--------------
This is the right Scripting after amendment, experience and confirmation

Reply with quote | Report
Post Re: dynamic dns script mikrotik
by bitmdn on Sunday, October 30, 2016

already solved by myself

Reply with quote | Report
Post Re: dynamic dns script mikrotik
by Mateito on Friday, December 30, 2016

How did you solve it

please

Reply with quote | Report
Post Re: Re: dynamic dns script mikrotik
by aghsistemas on Monday, August 7, 2017

Mateito wrote:How did you solve it

please
didn´t work for me too

Reply with quote | Report
Sunday, June 16, 2019 9:57 PM