Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # No-IP automatic Dynamic DNS update
- # Michael Martins - 2019
- # O Script faz o envio das informações para a sua conta No-IP
- # Após inserir o Script no Mikrotik, Criar um Scheduler para executar o Script de acordo com sua necessidade.
- #--------------- Modifique os valores nessa área de acordo com suas configurações ------------------
- # SUAS INFORMAÇÕES DA CONTA NO-IP EMAIL E SENHA
- :local noipuser "XXXXXXX@hotmail.com"
- :local noippass "XXXXXXX"
- # HOSTNAME QUE SERÁ ATUALIZADO
- # Hostnames with spaces are unsupported. Replace the value in the quotations below with your host names.
- # PARA ESPECIFICAR VÁRIOS HOSTS, SEPARAR POR VÍRGULA.
- :local noiphost "sunshinenetwork.ddns.net"
- # MODIFIQUE ABAIXO A INTERFACE E COLOQUE A QUE RECEBE O IP DINÂMICO DA OPERADORA
- # Change to the name of interface that gets the dynamic IP address
- :local inetinterface "pppoe-out1"
- #------------------------------------------------------------------------------------
- # NÃO É NECESSÁRIO FAZER NENHUMA ALTERAÇÃO ABAIXO
- :global previousIP
- :if ([/interface get $inetinterface value-name=running]) do={
- # Get the current IP on the interface
- :local currentIP [/ip address get [find interface="$inetinterface" disabled=no] address]
- # Strip the net mask off the IP address
- :for i from=( [:len $currentIP] - 1) to=0 do={
- :if ( [:pick $currentIP $i] = "/") do={
- :set currentIP [:pick $currentIP 0 $i]
- }
- }
- :if ($currentIP != $previousIP) do={
- :log info "No-IP: Current IP $currentIP is not equal to previous IP, update needed"
- :set previousIP $currentIP
- # The update URL. Note the "\3F" is hex for question mark (?). Required since ? is a special character in commands.
- :local url "http://dynupdate.no-ip.com/nic/update\3Fmyip=$currentIP"
- :local noiphostarray
- :set noiphostarray [:toarray $noiphost]
- :foreach host in=$noiphostarray do={
- :log info "No-IP: Sending update for $host"
- /tool fetch url=($url . "&hostname=$host") user=$noipuser password=$noippass mode=http dst-path=("no-ip_ddns_update-" . $host . ".txt")
- :log info "No-IP: Host $host updated on No-IP with IP $currentIP"
- }
- } else={
- :log info "No-IP: Previous IP $previousIP is equal to current IP, no update needed"
- }
- } else={
- :log info "No-IP: $inetinterface is not currently running, so therefore will not update."
- }
Add Comment
Please, Sign In to add comment