Community discussions

MikroTik App
 
ElFonte
just joined
Topic Author
Posts: 1
Joined: Mon Oct 30, 2017 2:04 am

ZoneEdit dynamic IP update script

Mon Oct 30, 2017 2:13 am

Hello, my name is Pablo from Argentina, new to the forums but user of mikrotik for a few years
I've run into a lot of problems while trying to update the IP of my ZoneEdit dynamic DNS account. There was no script available, and when I tried to change a existing script, the server would reject all my login attempts and return all sorts of errors, so I decided to submit my script when it finally worked
I took the code from the wiki for DynDNS, so credits to whoever made it
# Define login variables. Tested using Token, should work with password too
:global ddnsuser "USERNAME"
:global ddnspass "TOKEN"
# Define WAN interface name
:global theinterface "ether1-gateway"
# Define domain to update
:global ddnshost "DOMAIN"

:global ipddns [:resolve $ddnshost];
:global ipfresh [ /ip address get [/ip address find interface=$theinterface ] address ]
:if ([ :typeof $ipfresh ] = nil ) do={
   :log info ("ZoneEdit: No ip address on $theinterface .")
} else={
   :for i from=( [:len $ipfresh] - 1) to=0 do={ 
      :if ( [:pick $ipfresh $i] = "/") do={ 
    :set ipfresh [:pick $ipfresh 0 $i];
      } 
}
 
:if ($ipddns != $ipfresh) do={
    :log info ("ZoneEdit: IP-DNS = $ipddns")
    :log info ("ZoneEdit: IP-Fresh = $ipfresh")
   :log info "ZoneEdit: Update IP needed, Sending UPDATE...!"
   /tool fetch url="https://dynamic.zoneedit.com/auth/dynamic.html?host=$ddnshost&dnsto=$ipfresh" mode=https user=$ddnsuser password=$ddnspass dst-path=("/ZoneEdit.".$ddnshost)
    :delay 1
    :global str [/file find name="ZoneEdit.$ddnshost"];
    /file remove $str

    :global ipddns $ipfresh
  :log info "ZoneEdit: IP updated to $ipfresh!"
    } else={
     :log info "ZoneEdit: dont need changes";
    }
} 
Please note that it works on HTTPS, and I haven't tested it with password instead of the token as it's not recommended
Hope it helps someone
 
Royseen66
just joined
Posts: 2
Joined: Tue Nov 23, 2021 8:02 pm

Re: ZoneEdit dynamic IP update script

Fri Dec 03, 2021 3:48 pm

Is this script still up to date and can I run it on SwOs?

Who is online

Users browsing this forum: No registered users and 24 guests