Duck DNS Update Script for MikroTik RouterOS 6.XX Behind NAT
Voglio condividere questo script con voi, sono partito modificando una base che ho trovato googlando su internet.
Questa versione riesce a lavorare anche sulle versioni 6xx ed in pratica aggiorna le zone DNS
dell’ottimo servizio gratuito DUCKDNS su Mikrotik che sono dietro NAT utilizzando il mio blog come tramite.
# Duck DNS Update Script for MikroTik 6XX RouterOS behind NAT
#--------------- Change Values in this section to match your setup ------------------
:local ducktoken "your-token"
:local duckdomain "your-domain"
:local ddnshost "$duckdomain.duckdns.org"
#------------------------------------------------------------------------------------
# No more changes need
:local ipddns [:resolve $ddnshost]
/tool fetch mode=http url="http://www.ubuntuserver.it/indirizzo.php" src-path="/" dst-path="/wan.txt"
:delay 3
:local result [/file get wan.txt contents]
:local resultLen [:len $result]
:local endLoc [:find $result "\n" -1]
:log info "Lungh: $resultLen"
:log info "end: $endLoc"
:local ipfresh [:pick $result 0 $endLoc]
:log info "Duck DNS: L'indirizzo IP recuperato da ubuntuserver.it e' $ipfresh"
:if ($ipddns != $ipfresh) do={
:log info "Duck DNS: Il vecchio IP e' $ipddns"
:log info "Duck DNS: Il nuovo IP e' $ipfresh"
/tool fetch url="http://www.duckdns.org/update\?domains=$duckdomain&token=$ducktoken&ip=$ipfresh" dst-path=duckdns.txt
:global ipddns $ipfresh
:log info "Duck DNS: IP aggiornato a $ipfresh!"
} else={
:log info "Duck DNS: L'IP attuale e' $ipddns!"
:log info "Duck DNS: L'IP recuperato e' uguale a quello corrente, non effettuo modifiche."
}
}
Se vi è stato utile offritemi una birra 😀
Submit a Comment