Cum să adăugăm DDNS pe Mikrotik

– ne vom folosi pentru mikrotik de changeip.com pentru că este DDNS gratuit și stabil.ddns

– facem cont pe changeip.com, mergem la DNS Manager (în meniul din dreapta) și adaugăm un domeniu gratuit:

 

– acum intrăm pe mikrotik cu winbox sau ssh și dăm Paste la următorul cod (schimbați în prealabil ce este cu rosu marcat):

/system script

add name=ddns policy=\
ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api \
source=”# HomingBeacon Main Dynamic DNS Update Script\r\
\n\r\
\n# Set your specific ChangeIP.com preferences here.\r\
\n:global ddnsuser \”userul-tau\”\r\
\n:global ddnspass \”parola-ta\”\r\
\n:global ddnshost \”domeniul-tau\”\r\
\n# Change ddnsport to 8245 to bypass proxy.\r\
\n:local ddnsport 8245\r\
\n\r\
\n# Do not edit anything below this line.  You have been warned.\r\
\n# Abusive updates to the system will cause firewall blocks.\r\
\n\r\
\n# Please be considerate and\r\
\n# do not let this script run more than once per 3-5 minutes.\r\
\n\r\
\n:log info \”DDNS: Starting.\”\r\
\n\r\
\n# Initialize checkpoint\r\
\n:global ddnscheckpoint\r\
\n:if ([:typeof \$ddnscheckpoint] = \”time\”) do={\r\
\n\t:log info (\”DDNS: Last check was \” . ([/system clock get time] – \$d\
dnscheckpoint))\r\
\n} else={\r\
\n\t:log info \”DDNS: Cannot determine checkpoint, set now.\”\r\
\n\t:global ddnscheckpoint ( [/system clock get time] – 1d )\r\
\n}\r\
\n\r\
\n# Get the current IP\r\
\n:if ([/system clock get time] – \$ddnscheckpoint > [:totime 180s] || [/s\
ystem clock get time] – \$ddnscheckpoint < [:totime 0s]) do={\r\
\n   :log info \”DDNS: Performing remote IP detection.\”\r\
\n   /tool fetch address=\”ip.changeip.com\” host=\”ip.changeip.com\” src-\
path=(\”/\?\” . [/int eth get 0 mac-address ]) dst-path=\”ip.changeip.com.\
txt\” mode=http port=\$ddnsport\r\
\n   :global ddnscheckpoint [/system clock get time]\r\
\n} else={\r\
\n   :log info \”DDNS: Please be considerate and wait a few seconds longer\
.\”\r\
\n   :break\r\
\n}\r\
\n\r\
\n# Parse the IP address received from fetch script.\r\
\n\t:global ddnslastip\r\
\n\t:local html [/file get \”ip.changeip.com.txt\” contents]\r\
\n\t:local ddnsip [:pick \$html ([:find \$html \”<!–IPADDR=\”] + 11) [:fi\
nd \$html \”–>\”] ]\r\
\n\r\
\n# Is it a valid IP and is it different than the last one\?\r\
\n\t:if ([:typeof [:toip \$ddnsip]] = \”ip\” AND \$ddnsip != \$ddnslastip \
) do={\r\
\n\t\t:log info \”DDNS: Sending UPDATE with \$ddnsip\”\r\
\n\t\t:log info [/tool dns-update name=\$ddnshost address=\$ddnsip key-nam\
e=\$ddnsuser key=\$ddnspass ]\r\
\n\t\t:global ddnslastip \$ddnsip\r\
\n\t} else={\r\
\n\t\t:log info \”DDNS: No update required.\”\r\
\n\t}\r\
\n}\r\
\n”

– o să arate ceva de genul:

mikrotik

– acum verificăm în System / Scripts din mikrotik dacă a apărut scriptul nostru, și ar trebui sa apară ceva de genul:

m2

– dăm click pe Run Script și verificăm în changeip.com ce ip avem alocat (dând click pe domeniul creat mai devreme), și vom avea ceva de genul:

m3

– acum punem și setarea de actualizare la 5 minute a ip-ului, la fel ca mai sus, deschidem din Winbox, New Terminal sau din ssh și dăm paste la următoarele comenzi:

/system scheduler
add disabled=no interval=5m name=”Ruleaza DDNS la fiecare 5 minute” on-event=update-ddns policy=\
ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api start-date=mar/26/2014 start-time=12:00:00

– acum verificăm în Winbox în System / Scheduler și scriptul va trebui să fie acolo și va spune și următoarea oră când va verifica și când a verificat ultima data.

– din acest moment va răspunde la domeniul ales de noi, ip-ul alocat dinamic.

 


 

Ultimele știri mikrotik:

 

 

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *