This page has been translated from Italian
Octobre
07e

Utilisation avec DynDNS RouterOS

| 2 commenti | TrackBack | | | 2 commentaires | TrackBack |
una stelladue stelletre stellequattro stellecinque stelle (Noter cet article!)
Loading ... Chargement en cours ...

Le script ci-dessous permet à ceux qui ont un Routerboard Mikrotik ou un système chargé avec RouterOS de mettre à jour l'adresse sur votre compte DynDns.org .

Le script doit être configurée, le nom d'hôte doit être mis à jour, le nom d'utilisateur et mot de passe de votre compte DynDNS et l'interface sur laquelle l'adresse est attribuée dynamiquement par le fournisseur.

Le script suivant, lorsqu'il est exécuté, mettre à jour la configuration de votre

:global ddnsuser "YOUR_USERNAME"
:global ddnspass "YOUR_PASSWORD"
:global ddnshost "YOUR.DOMAIN.EXT"
:global ddnsinterface "THE_INTERFACE"

:global ddnsip [ /ip address get [/ip address find interface=$ddnsinterface] address ]
:global ddnslastip
:if ([:len [/interface find name=$ddnsinterface]] = 0 ) do={ :log info "DDNS: No interface named $ddnsinterface, please check configuration." }
:if ([ :typeof $ddnslastip ] = "nothing" ) do={ :global ddnslastip 0.0.0.0/0 }
:if ([ :typeof $ddnsip ] = "nothing" ) do={
:log info ("DDNS: No ip address present on " . $ddnsinterface . ", please check.")
} else={
  :if ($ddnsip != $ddnslastip) do={
    :log info "DDNS: Sending UPDATE!"
    :local ddnsip1 [:pick $ddnsip 0 [:find $ddnsip "/"] ];
    :local str "/nic/update?hostname=$ddnshost&myip=$ddnsip1";
    /tool fetch address=members.dyndns.org 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
  } else={
    :log info "DDNS: No changes necessary."
  }
}

Questo script può, ovviamente essere eseguito automaticamente, ogni ora o anche meno, usando lo scheduler.

Riporto qui sotto, per comodità, i comandi da incollare in una finestra del terminale del winbox, che aggiungono lo script sopra e uno scheduler che esegue lo script ogni 10 minuti

/system script
add name="DynDNS update" policy=\
ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive source="\
:global ddnsuser \"YOUR_USERNAME\"\r\
\n:global ddnspass \"YOUR_PASSWORD\"\r\
\n:global ddnshost \"YOUR.DOMAIN.EXT\"\r\
\n:global ddnsinterface \"THE_INTERFACE\"\r\
\n:global ddnsip [ /ip address get [/ip address find interface=\$ddnsinter\
face] address ]\r\
\n:global ddnslastip\r\
\n:if ([:len [/interface find name=\$ddnsinterface]] = 0 ) do={ :log info \
\"DDNS: No interface named \$ddnsinterface, please check configuration.\" \
}\r\
\n:if ([ :typeof \$ddnslastip ] = \"nothing\" ) do={ :global ddnslastip 0.\
0.0.0/0 }\r\
\n:if ([ :typeof \$ddnsip ] = \"nothing\" ) do={\r\
\n:log info (\"DDNS: No ip address present on \" . \$ddnsinterface . \", p\
lease check.\")\r\
\n} else={\r\
\n  :if (\$ddnsip != \$ddnslastip) do={\r\
\n    :log info \"DDNS: Sending UPDATE!\"\r\
\n\t:local ddnsip1 [:pick \$ddnsip 0 [:find \$ddnsip \"/\"] ];\r\
\n\t:local str \"/nic/update\?hostname=\$ddnshost&myip=\$ddnsip1\";\r\
\n    /tool fetch address=members.dyndns.org src-path=\$str mode=http user\
=\$ddnsuser password=\$ddnspass dst-path=(\"/DynDNS.\".\$ddnshost)\r\
\n    :delay 1\r\
\n    :local str [/file find name=\"DynDNS.\$ddnshost\"];\r\
\n    /file remove \$str\r\
\n    :global ddnslastip \$ddnsip\r\
\n  } else={ \r\
\n    :log info \"DDNS: No changes necessary.\"\r\
\n  }\r\
\n}"

/system scheduler
add comment="" disabled=no interval=1h name="Schedule DynDNS Update" \
on-event="/system script run \"DynDNS update\"" policy=\
reboot,read,write,policy,test,password,sniff,sensitive start-time=startup
Questo articolo è stato visto 386 volta

2 Responses to “Usare DynDns con RouterOs”

Lascia un commento

 

Categorie

Articoli Più Visti

Questo articolo è stato visto 386 volta

2 Responses to “Usare DynDns con RouterOs”

Lascia un commento

 

Categorie