Dica - Script para DNS Dinamico (DynDNS)
Boa noite pessoal, segue um script para dns dinamico compativel com o site DynDNS.com: Free DNS Hosting, E-mail Delivery, and VPS Hosting , um dos melhores na minha opiniao. É uma alternativa ao famoso Changeip. Segue abaixo o script, altere as variaveis conforme a nescessidade.
No Winbox, Vá até o menu System..Scripts, adicone ..de o nome dyndns e cole o conteudo abaixo:
Código :
# Define User Variables
:global ddnsuser "DYNDNSUSER"
:global ddnspass "DYNDNSPASS"
:global ddnshost "DYNDNSHOST"
# 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&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"
/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
}
}
Depois, vá até New Terminal, e adicione um Scheduler para rodar o script a cada X minutos...no exemplo abaixo é para rodar a cada 2 minutos.
Código :
/system scheduler add name=dynDNS interval=2m on-event="/system script run dyndns\r\n"
Obs: Script compativel apenas com as versoes igual ou superior a 3.13 do Mikrotik (nas quais eu testei)
Fonte: Dynamic DNS Update Script for dynDNS - MikroTik Wiki
Se foi util, agradeça ;)