
Prerequisiti
Prima di procedere con la configurazione è necessario:
- Selezionare un abbonamento dynDNS.it;
- Creare un account dynDNS.it;
- Creare una connessione .it nella Gestione Host.
CONFIGURAZIONE
CONNESSIONE .IT NATIVAAbbonamento consigliato
Standard dynDNS.itConfigurazione rapida
Dopo aver creato una connessione .it nativa prendere nota del nome host creato completo di dominio, del nome utente e della password utilizzate per accedere al sito dynDNS.it. A questo punto è possibile accedere al proprio router Mikrotik ed inserire i dati necessari alla configurazione.
I dati necessari alla configurazione saranno, ad esempio:
Fornitore del servizio
dyndns.it
Nome Host
myhost.homepc.it
Username
myusername (usata per accedere a dynDNS.it)
Password
mypassword (usata per accedere a dynDNS.it)
Configurazione guidata
La configurazione di dispositivi Mikrotik può essere effettuata in due varianti:
- Mikrotik con checkip: Configurazione di dynDNS.it classica con verifica del cambio dell’IP su servizio esterno. Non genera aggiornamenti illeciti.
- Mikrotik senza checkip: Configurazione di dynDNS.it su Mikrotik quando l’IP pubblico è assegnato direttamente alla porta esterna e non cambia. Da chiamarsi una sola volta.
1. Mikrotik con checkip
# Set needed variables :local username "dyndns.it username" :local password "dyndns.it password" :local hostname "your_hostname.homepc.it" :global dyndnsForce :global previousIP # print some debug info :log info ("UpdateDynDNS: username = $username") :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" :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 available at http://www.dyndns.com/developers/specs/syntax.html :if (($currentIP != $previousIP) || ($dyndnsForce = true)) do={ :set dyndnsForce false :set previousIP $currentIP /tool fetch user=$username password=$password mode=http address="update.dyndns.it" src-path="/nic/update?hostname=$hostname&myip=$currentIP" dst-path="/dyndns.txt" :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") }
Lo script deve essere eseguito dallo scheduler una volta al minuto per vericare il cambio IP.
/system scheduler add name=dynDNSit interval=00:01 on-event=&quot;/system script run dynDnsIT\r\n&quot;
2. Mikrotik senza checkip
# Define User Variables :global ddnsuser "DYNDNSITUSER" :global ddnspass "DYNDNSITPASS" :global ddnshost "DYNDNSITHOST.homepc.it" # Define Global Variables :global ddnsip :global ddnslastip :if ([ :typeof $ddnslastip ] = nil ) do={ :global ddnslastip "0" } :global ddnsinterface :global ddnssystem ("mt-" . [/system package get system version] ) # Define Local Variables :local int # Loop thru interfaces and look for ones containing # default gateways without routing-marks :foreach int in=[/ip route find dst-address=0.0.0.0/0 active=yes ] do={ :if ([:typeof [/ip route get $int routing-mark ]] != str ) do={ :global ddnsinterface [/ip route get $int interface] } } # Grab the current IP address on that interface. :global ddnsip [ /ip address get [/ip address find interface=$ddnsinterface ] address ] # Did we get an IP address to compare? :if ([ :typeof $ddnsip ] = nil ) do={ :log info ("DynDNS: No ip address present on " . $ddnsinterface . ", please check.") } else={ :if ($ddnsip != $ddnslastip) do={ :log info "DynDNS: Sending UPDATE!" :local str "/nic/update?hostname=$ddnshost&myip=$ddnsip" /tool fetch address=update.dyndns.it src-path=$str mode=http user=$ddnsuser \ password=$ddnspass dst-path=("/DynDNS.".$ddnshost) :delay 1 :local str [/file find name="DynDNS.$ddnshost"]; /file remove $str :global ddnslastip $ddnsip } }
Tutti i marchi e le immagini sono dei rispettivi proprietari che ne detengono tutti i diritti per legge.
Prossimi Step
- Configura il Port Forwarding per instradare la connessione al dispositivo che desideri raggiungere;
- Accedi alla Gestione Host per visualizzare il primo aggiornamento ricevuto.