I made a few changes to it, and it seemed to run just fine. It updates my IP after correctly after I reboot the router. But when my IP changes afterwards, it simply does not work anymore until I reboot again. So, when the IP changes and the script runs:
- The variable $network is empty (check out the script to see what I mean). It should not be empty because there is a new IP on the interface… So this piece of code does not seem to work anymore:
:local network [/ip address get number=1 address]
- The variable $length is null (obvious, since $network is empty)
If anyone can tell me what is wrong, I’d be very happy:-)
Thank you,
Jeroen
# Dynamic DNS Update / Simple Edition
# Written by Sam Norris, ChangeIP.com
# Copyright ChangeIP.com 2009-2010
# For support send mail to Support@ChangeIP.com
#
# 2009-06-22 RouterOS 3.25 Tested
# 2009-10-05 RouterOS 4.01rc1 Tested
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# EDIT YOUR DETAILS / CONFIGURATION HERE
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:global ddnsuser "INFO REMOVED"
:global ddnspass "INFO REMOVED"
:global ddnshost "INFO REMOVED"
:global ddnsinterface "WAN"
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# END OF USER DEFINED CONFIGURATION
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:global ddnssystem ("mt-" . [/system package get [/system package find name=system] version] )
#:global ddnsip [ /ip address get [/ip address find interface=$ddnsinterface] address ]
:global ddnslastip
:local network [/ip address get number=1 address]
:log info (" network is $network")
:local length [:len $network]
:log info ("length is $length")
:local ddnsip [:pick $network 0 ($length-3)]
:log info ("Fetched IP address is $ddnsip")
#: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!"
:log info [ :put [/tool dns-update name=$ddnshost address=$ddnsip key-name=$ddnsuser key=$ddnspass ] ]
:global ddnslastip $ddnsip
} else={
:log info "DDNS: No changes necessary."
}
}
# END OF SCRIPT