Indice   FAQ  
Iscriviti  Login
Indice Networking & Software di geolocalizzazione DynamicDNS

Script dynu

Ecco come sfruttare un IP dinamico

Script dynu

Messaggioda arkam » lun 7 set 2020, 13:58

Salve a tutti, avrei bisogno di un piccolo aiutino.
sto cercando di utilizzare uno script per aggiornare il mio ip su un dns dynu però ho qualche problemino, del tipo che continua ad aggiornarmi come ip 0.0.0.1 pure se effettua il controllo correttamente.
lo script che uso è quello per aggiornare dyndns ma naturalmente con parametri aggiornati.
di seguito vi posto gli script.
Script dyndns:
Codice: Seleziona tutto
# Set needed variables
:local username "xxxxxx"
:local password "xxxxxxxxx"
:local hostname "xxxxxx"
:local previousIP [:put [:resolve $hostname]];
#:delay 1
:global dyndnsForce
:global previousIP

# print some debug info
:log info ("UpdateDynDNS: username = $username")
:log info ("UpdateDynDNS: password = $password")
:log info ("UpdateDynDNS: hostname = $hostname")
:log info ("UpdateDynDNS: previousIP = $previousIP")

# get the current IP address from the internet (in case of double-nat)
/tool fetch mode=http address="checkip.dyndns.it" src-path="/" dst-path="/dyndns.checkip.html"
#:delay 1
:local result [/file get dyndns.checkip.html contents]

# parse the current IP result
: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]
:log info "UpdateDynDNS: currentIP = $currentIP"

# Remove the # on next line to force an update every single time - useful for debugging,
# but you could end up getting blacklisted by DynDNS!

#:set dyndnsForce true

# Determine if dyndns update is needed
# more dyndns updater request details https://help.dyn.com/remote-access-api/return-codes/

:if (($currentIP != $previousIP) || ($dyndnsForce = true)) do={
:set dyndnsForce false
:set previousIP $currentIP
#:log info "$currentIP or $previousIP"
/tool fetch user=$username password=$password mode=http address="update.dyndns.it" \
src-path="nic/update?system=dyndns&hostname=$hostname&myip=$currentIP&wildcard=no" \
dst-path="/dyndns.txt"
#:delay 1
:local result [/file get dyndns.txt contents]
:log info ("UpdateDynDNS: Dyndns update needed")
:log info ("UpdateDynDNS: Dyndns Update Result: ".$result)
:put ("Dyndns Update Result: ".$result)
} else={
:log info ("UpdateDynDNS: No dyndns update needed")
}


Script dynu:
Codice: Seleziona tutto
# Set needed variables
:local username "xxxxxx"
:local password "xxxxxxx"
:local hostname "xxxxxxxx"
:local previousIP [:put [:resolve $hostname]];
#:delay 1
:global dynuForce
:global previousIP

# print some debug info
:log info ("UpdateDynu: username = $username")
:log info ("UpdateDynu: password = $password")
:log info ("UpdateDynu: hostname = $hostname")
:log info ("UpdateDynu: previousIP = $previousIP")

# get the current IP address from the internet (in case of double-nat)
/tool fetch mode=http address="checkip.dynu.com" src-path="/" dst-path="/dynu.checkip.html"
#:delay 1
:local result [/file get dynu.checkip.html contents]

# parse the current IP result
: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]
:log info "UpdateDynu: currentIP = $currentIP"

# Determine if dynu update is needed
# more dyndns updater request details https://help.dyn.com/remote-access-api/return-codes/

:if (($currentIP != $previousIP) || ($dynuForce = true)) do={
:set dynuForce false
:set previousIP $currentIP
#:log info "$currentIP or $previousIP"
/tool fetch user=$username password=$password mode=http address="api.dynu.com" \
src-path="nic/update?system=dynu&hostname=$hostname&myip=$currentIP&wildcard=no" \
dst-path="/dynu.txt"
#:delay 1
:local result [/file get dyndns.txt contents]
:log info ("UpdateDynu: Dyndns update needed")
:log info ("UpdateDynu: Dyndns Update Result: ".$result)
:put ("Dyndns Update Result: ".$result)
} else={
:log info ("UpdateDynu: No dyndns update needed")
}

In allegato trovate quello che esce nei log.
Spero in un vostro aiuto.
Saluti
Non hai i permessi necessari per visualizzare i file allegati in questo messaggio.
arkam
Mikrotik Curious User
Mikrotik Curious User
 
Messaggi: 5
Iscritto il: mer 12 nov 2014, 22:31

Re: Script dynu

Messaggioda Gerrym » ven 15 ott 2021, 11:30

Ciao arkam
non so se ho capito bene ma prova a dare una letta qui https://dyndns.it/guide/configurazione-dyndns-it-mikrotik/

saluti
Gerrym
Mikrotik Curious User
Mikrotik Curious User
 
Messaggi: 4
Iscritto il: sab 15 mag 2010, 14:38



Torna a DynamicDNS

Chi c’è in linea

Visitano il forum: Nessuno e 1 ospite