add for mikrotik add for mikrotik

Topic: add for mikrotik

Post add for mikrotik
by wesam alazade on Monday, August 17, 2015

how to add dns for mikrotik server

Reply with quote | Report
Post Re: add for mikrotik
by timothytw on Tuesday, August 18, 2015

1) add a script called Dynu.

----------

: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";
}
}
--------------

Please change the values in bold with your 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

2) After manually tested that it works, you can add a script to run the update every 5 minutes:

/system scheduler add comment="Update Dynu DDNS" disabled=no interval=5m \ name=Dynu on-event=Dynu policy=read,write,test

Reply with quote | Report
Tuesday, April 23, 2019 3:40 AM