Indice   FAQ  
Iscriviti  Login
Indice RouterOS RouterOS

Script DynDNS

Tutto su questo sistema operativo linux based - Configurazioni, dubbi, problematiche &....

Script DynDNS

Messaggioda Blodoksmobile » mar 24 mar 2015, 11:26

Buongiorno ragazzi!
Ultimamente mi sono trovato davanti ad alcuni sistemi i cui LOG erano per gran parte composti da informazioni riguardanti gli update di DynDNS o il parsing degli IP seguito da "Update non necessario".
Forse avrò compilato io uno script troppo "logorroico", fatto sta che l'ho snellito un po' ed a mio parere è molto più comodo!

Volevo solo condividere con voi questo script, non si sa mai che a qualcuno torni utile! [ok]

Codice: Seleziona tutto
####### VARIABILI LOCALI #######

:local username “ACCOUNT”
:local password “PASSWORD”
:local hostname “INDIRIZZO.DYNDNS.COM”

:global dyndnsForce "false"
:global previousIP

####### CONTROLLO DEGLI IP #######

/tool fetch mode=http address="checkip.dyndns.org" src-path="/" dst-path="/dyndns.checkip.html"
:local result [/file get dyndns.checkip.html contents]


####### IP PARSING #######

:local resultLen [:len $result]
:local startLoc [:find $result ": " -1]
:set startLoc ($startLoc + 2)
:local endLoc [:find $result "</body>" -1]
:local currentIP [:pick $result $startLoc $endLoc]

####### NECESSITA' DI UPDATE #######

:if (($currentIP != $previousIP) || ($dyndnsForce = true)) do={
:log info "======================== DYNDNS UPDATE ========================="
:log info ("UpdateDynDNS: hostname = $hostname")
:log info ("UpdateDynDNS: previousIP = $previousIP")
:log info "UpdateDynDNS: currentIP = $currentIP"
:set dyndnsForce false
:set previousIP $currentIP
/tool fetch user=$username password=$password mode=http address="members.dyndns.org" \
src-path="nic/update?system=dyndns&hostname=$hostname&myip=$currentIP&wildcard=no" \
dst-path="/dyndns.txt"
:local result [/file get dyndns.txt contents]
:log info ("UpdateDynDNS: Dyndns Update Result: ".$result)
:log info "================================================================"
:put ("Dyndns Update Result: ".$result)
} else={
:log info "================================================================"
:log info "                                    DNS CHECK NOT NEEDED ON $currentIP                       "
:log info "================================================================"
}


Spero di esservi stato utile, a presto!! [bye]
Blodoksmobile
Mikrotik-User 10° Liv
Mikrotik-User 10° Liv
 
Messaggi: 28
Iscritto il: lun 12 mar 2012, 11:17

Re: Script DynDNS

Messaggioda figheras » gio 2 apr 2015, 10:50

Grazie per il tuo contributo...ma per tua informazione non è piu necessario utilizzare DynDns da quando mikrotik ha incluso dalla versione 6.16 la funzione "cloud" che ti permette di assegnare un dominio al tuo indirizzo pubblico e di aggiornarlo in automatomatico, ed il tutto è completamente gratutito!
Per attivare la funzione:
Codice: Seleziona tutto
ip cloud set enabled=yes
Siamo tutti ignoranti. Ma non tutti ignoriamo le stesse cose! - Einstein -
Avatar utente
figheras
Staff rosIT
Staff rosIT
 
Messaggi: 1218
Iscritto il: sab 19 set 2009, 20:09
Uso routerOS dalla Versione: v2.9.x
Certificazioni Mikrotik: MTCNA, MTCRE, MTCWE
Altre certificazioni: Cisco CCNA, KalliopePBX
Preferred Training Centre: Grifonline



Torna a RouterOS

Chi c’è in linea

Visitano il forum: Nessuno e 4 ospiti