Dupa ce am publicat in articolul DUIA Custom URL / Tomato o modalitate prin care poti folosi DUIA (dynamic DNS v4/v6) pe un router cu Tomato / OpenWRT, am primit mai multe mailuri din partea celor care folosesc Mikrotik pentru a le oferi si lor ceva similar.
Iata mai jos doua exemple de scripturi (unul pentru IPv4 unul pentru IPv6) pe care le puteti pune sa ruleze in scheduler, la 5 minute, pentru IPv4 / IPv6 update.
Pas 1: Mergeti in contul vostru la Account InfoL ca sa aflati valorile pentru variabila “duiapassmd5”.
Pas 2: Faceti COPY la scriptul de mai jos pentru IPv4 (nu uita ca cele 3 variabile sa fie completate cu detaliile tale de la punctul 1)
# Define User Variables # click aici
:global duiapassmd5 ""
:global duiahost ""
:global duiaForce false
# Define Global Variables
:global currentIP;
:log info “DynDNS: $currentIP”
:tool fetch url=”http://ipv4.duia.ro” dst-path=”/duia.checkip.html”
:delay 1
:local result [/file get duia.checkip.html contents]
# parse the current IPv4 result
:local resultLen [:len $result]
:local endLoc [:find $result “\n” -1]
:local newIP [:pick $result 0 $endLoc]
:file remove duia.checkip.html
:if (($newIP != $currentIP) || ($duiaForce = true)) do={
:set duiaForce false
:put “ip address $currentIP changed to $newIP”;
:set currentIP $newIP;
:log info “DynDNS update: $newIP”
:tool fetch \
url=”http://www.duia.ro/dynamic.duia\?host=$duiahost&password=$duiapassmd5&ip4=$newIP”
}
Pas 3: Mergeti in interfata de configurare a Mikrotik-ului la System -> Scripts si faceti PASTE la codul de mai sus (vezi si poza de mai jos):
Pas 4: Faceti COPY la scriptul de mai jos pentru IPv6 (nu uitati sa completati duiapassmd5 si duiahost)
# Define User Variables # click aici
:global duiapassmd5 ""
:global duiahost ""
:global duiaForce false
# Define Global Variables
:global currentIPv6;
:log info “DynDNS: $currentIPv6″
:tool fetch url=”http://ipv6.duia.ro” dst-path=”/duia.checkip.html”
:delay 1
:local result [/file get duia.checkip.html contents]
# parse the current IP result
:local resultLen [:len $result]
:local endLoc [:find $result “\n” -1]
:local newIPv6 [:pick $result 0 $endLoc]
:file remove duia.checkip.html
:if (($newIPv6 != $currentIPv6) || ($duiaForce = true)) do={
:set duiaForce false
:put “ip address $currentIPv6 changed to $newIPv6”;
:set currentIPv6 $newIPv6;
:log info “DynDNS update: $newIPv6″
:tool fetch \
url=”http://www.duia.ro/dynamic.duia\?host=$duiahost&password=$duiapassmd5&ip4=$newIPv6”
}
Pas 5: Mergeti in interfata de configurare a Mikrotik-ului la System -> Scripts, faceti PASTE la codul de mai sus (vezi si poza de la punctul 3):
Pas 6: Tot in interfata de configurare a Mikrotik-ului mergeti la System -> Scheduler si adaugati scriptul sa ruleze in bucla la 5 minute (vezi si poza de mai jos):
Aveti asadar doua scripturi, care ruleaza pe routerul vostru Mikrotik si fac update in DNS la adresele IPv4 si IPv6 daca acestea s-au schimbat intre timp. Am preferat sa fac doua scripturi diferite pentru v4 si v6 pentru ca daca as fi pus tot codul intr-un singur script, in situatia in care nu ati fi avut decat IPv4 pe masina, ar fi putut aparea probleme.
Thanks for nice tutorial. But I did all the things and RB still didn’t update dynDNS. When I manualy create an URL – everythings work fine.
What I did wrong?
@Tyler: what i see in my logs is that you’re using v4 only and your script is running every 5 minutes. nothing wrong here !
did you correctly define your variables (don’t forget the quotes “..”) ?
https://www.duiadns.net/account/custom_url.html
# Define User Variables
:global duiauser “”
:global duiapassmd5 “”
:global duiahost “”
what errors do you see in mikrotik logs ?
I’m sorry. Everything works.
I can’t connect to my router from outside, but I think it’s because of my ISP.
Thanks for your help.