I have been searching high and low for a DNSDynamic update script.
I have tried the following:
Code: Select all
### DDNS script for www.no-ip.com, www.dnsdynamic.org,www.changeip.com and dyn.com based on DIPU - Dynamic IP Updater V1.5 ###
### Thanks to the original poster ###
### Peter James 2012-03-01 ###
### Remember to set up Tools - Email settings ###
###########################################################
################## START OF DEFINITIONS ##################
### Define name of interface you want this DDNS script to update ###
:local ddnsinterface "pppoe_out1"
### Define DDNS credentials ###
:local userDDNS "USER"
:local passDDNS "PASSWORD"
### hostDDNS is the host or group name
:local hostDDNS "YOUR HOST HERE"
####################################################################################################
### Choose the DDNS provider. Do not change address, as this will determine the update url later ###
## Use this for www.no-ip.com ##
#:local providerAddress "dynupdate.no-ip.com"
## or this for changeip.com
#:local providerAddress "nic.changeip.com"
## or this for www.dnsdynamic.org ##
:local providerAddress "www.dnsdynamic.org"
## or this for dyn.com ##
#:local providerAddress "members.dyndns.org"
# simply comment out the ones you do not need above #
####################################################################################################
### Define the email address to receive the DDNS update results ###
:local emailAddressToNotify "your_email_address"
### Define name of system scheduler that will call this script ###
:local SchedName "your_scheduler_name"
################## END OF DEFINITIONS ##################
########################################################
:local ddnsURL
### Check if defined interface exists ###
:if ([:len [/interface find name=$ddnsinterface]] > 0 ) do={
:local ddnsIntStat [/interface get [find name=$ddnsinterface] disabled];
### Check if interface is disabled ###
if (!$ddnsIntStat) do={
:log info "$ddnsinterface DDNS: Starting"
### Get the address of the specified wan interface ###
:local currentIP [/ip address get [find interface=$ddnsinterface] address];
:set currentIP [:pick $currentIP 0 [:find $currentIP "/"]]
:log info "$ddnsinterface DDNS: Current gateway IP is $currentIP"
### Now build the DDNS update url based on the selected provider ###
## for www.no-ip.com ##
if ($providerAddress="dynupdate.no-ip.com") do={:set ddnsURL ("/nic/update?hostname=$hostDDNS&myip=$currentIP")}
## for www.changeip.com ##
if ($providerAddress="nic.changeip.com") do={:set ddnsURL ("/nic/update?hostname=$hostDDNS&myip=$currentIP")}
## for www.dnsdynamic.org
if ($providerAddress="www.dnsdynamic.org") do={:set ddnsURL ("/api/?hostname=$hostDDNS&myip=$currentIP")}
## for members.dyndns.org ##
if ($providerAddress="members.dyndns.org") do={:set ddnsURL ("/nic/update?hostname=$hostDDNS&myip=$currentIP")}
### Do nothing if address is empty ###
:if ($currentIP != "") do={
#
### Get System Identity ###
:local SystemID [/system identity get name]
### get the current IP address from the internet (in case of double-nat)
#:log info "$ddnsinterface DDNS: Resolving Host $hostDDNS IP"
:local lastIP [:resolve $hostDDNS]
:log info "$ddnsinterface DDNS: Resolved Host $hostDDNS IP to $lastIP"
#
### Compare current IP with last, if changes detected perform update ###
:if ( $currentIP != $lastIP ) do={
:log info "$ddnsinterface DDNS: WAN IP change detected from $lastIP to $currentIP"
#
### Perform DDNS update ###
:log info "$ddnsinterface DDNS: DDNS built url: $ddnsURL"
:log info "$ddnsinterface DDNS: DDNS update being attempted"
/tool fetch address=$providerAddress dst-path="$ddnsinterface-DDNS.txt" src-path=$ddnsURL mode=http user=$userDDNS password=$passDDNS
:delay 2
:local ddnsOUT [/file get "$ddnsinterface-DDNS.txt" contents]
/tool e-mail send tls=yes subject="$SystemID $hostDDNS DNS update result" to=$emailAddressToNotify body="$SystemID $hostDDNS IP Address Change from $lastIP to $currentIP update result was '$ddnsOUT'"
:log info "$ddnsinterface DDNS: $SystemID $hostDDNS DDNS update result was '$ddnsOUT'"
### Note: Results do not apply to changeip.com, rather see the result in the log or email ###
:local resultString "'$ddnsOUT'"
### Email/Stop scheduler depending on the result from no-ip
:if ([find $resultString "good" -1] != "") do={
/tool e-mail send tls=yes subject="$SystemID $hostDDNS DNS hostname update successful" to=$emailAddressToNotify body="$SystemID $hostDDNS IP Address Changed from $lastIP to $currentIP DNS update result was $resultString"
} else={
:if ([find $resultString "nochg" -1] != "") do={
/tool e-mail send tls=yes subject="$hostDDNS IP address is current, no update performed" to=$emailAddressToNotify body="$hostDDNS IP remains $currentIP DNS update result was $resultString"
} else={
:if ([find $resultString "nohost" -1] != "") do={
/tool e-mail send tls=yes subject="$hostDDNS Error: Hostname supplied does not exist under specified account" to=$emailAddressToNotify body="$hostDDNS Scheduler stopped, DNS update result was $resultString"
:local scheduleId [/system scheduler find $SchedName]
/system scheduler disable $scheduleId
} else={
:if ([find $resultString "badauth" -1] != "") do={
/tool e-mail send tls=yes subject="$hostDDNS Error: Invalid username password combination" to=$emailAddressToNotify body="$hostDDNS Scheduler stopped, DNS update result was $resultString"
:local scheduleId [/system scheduler find $SchedName]
/system scheduler disable $scheduleId
} else={
:if ([find $resultString "badagent" -1] != "") do={
/tool e-mail send tls=yes subject="$hostDDNS Error: Client disabled. Client should exit and not perform any more updates without user intervention." to=$emailAddressToNotify body="$hostDDNS Scheduler stopped, DNS update result was $resultString"
:local scheduleId [/system scheduler find $SchedName]
/system scheduler disable $scheduleId
} else={
:if ([find $resultString "donator" -1] != "") do={
/tool e-mail send tls=yes subject="$hostDDNS Error: An update request was sent including a feature that is not available to that particular user such as offline options." to=$emailAddressToNotify body="$hostDDNS Scheduler stopped, DNS update result was $resultString"
:local scheduleId [/system scheduler find $SchedName]
/system scheduler disable $scheduleId
} else={
:if ([find $resultString "abuse" -1] != "") do={
/tool e-mail send tls=yes subject="$hostDDNS Error: Username is blocked due to abuse. Either for not following our update specifications or disabled due to violation of terms of service. Client should stop sending updates." to=$emailAddressToNotify body="$hostDDNS Scheduler stopped, DNS update result was $resultString"
:local scheduleId [/system scheduler find $SchedName]
/system scheduler disable $scheduleId
} else={
:if ([find $resultString "911" -1] != "") do={
/tool e-mail send tls=yes subject="$hostDDNS Error:A fatal error on our side such as a database outage. Retry the update no sooner 30 minutes." to=$emailAddressToNotify body="$hostDDNS Scheduler stopped, DNS update result was $resultString"
:local scheduleId [/system scheduler find $SchedName]
/system scheduler disable $scheduleId
}
}
}
}
}
}
}
}
#
###
:log info "$ddnsinterface DDNS: Update complete"
#
} else={
:log info "$ddnsinterface DDNS: No update required"
}
}
} else={
:log info "DDNS: $ddnsinterface is disabled. Please check configuration"
}
} else={
:log info "DDNS: No interface named $ddnsinterface, Please check configuration."
}
### End of script ##
I am using an RB951 with RouterOS6.7
I'd really appreciate a working script Or perhaps some pointers on what to do to get this script working.