Community discussions

MikroTik App
 
vexersa
just joined
Topic Author
Posts: 11
Joined: Mon Sep 30, 2013 3:37 pm

DNSDynamic Update Script

Wed Dec 11, 2013 2:50 pm

Hello people!

I have been searching high and low for a DNSDynamic update script.

I have tried the following:
### 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 ##
It doesn't work though unfortunately :(

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.
 
troy
Member
Member
Posts: 320
Joined: Thu Jun 30, 2005 6:47 pm

Re: DNSDynamic Update Script

Wed Dec 11, 2013 10:17 pm

Wow, that is a really long complicated script... but, I don't need all those email notifications and stuff. Crazy stuff!

Here's how I do it, short and simple:

ros code

#
## Script by Troy
##
## I don't remember what's stolen and what's original... use at your own risk
#
:global currentIP;

:local tmpIP [/ip address get [find interface="WAN"] address];
:local myIP [:pick $tmpIP 0 [:find $tmpIP "/"]];

:if ($myIP != $currentIP) do={
    :log info "WAN IP address changed from $currentIP to $myIP"
    :set currentIP $myIP;
    :foreach rule in=[/ip firewall nat find dst-address=$currentIP] do={
        /ip firewall nat set $rule dst-address=$myIP;
    }
    /tool fetch keep-result=no url="http://url.to.server/page?args&stuff"
}
Enjoy and give Karma if it helps!
 
Goasler
just joined
Posts: 11
Joined: Tue Nov 13, 2012 10:06 pm

Re: DNSDynamic Update Script

Wed May 14, 2014 8:33 pm

Hello,

for DNS Dnyamic http://www.dnsdynamic.org
at RouterOS v6.12 with RouterBoard 2011US-2HnD-In, i use (70% Created by me, 30% by troy):
:log info +++++++++++++-DNSUpdate-+++++++++++++
:global currentIP;
:local tmpIP [/ip address get [find interface="YOUR PPPOE WAN INTERFACE HERE"] address];
:local myIP [:pick $tmpIP 0 [:find $tmpIP "/"]];
:set currentIP $myIP;
:log info "YOUR IP: $currentIP"
/tool fetch user=YOURUSERNAMEHERE password=YOURPASSWORDHERE mode=https address="www.dnsdynamic.org" \
      src-path="api/?hostname=YOURdnsdynamicHOSTNAME&myip=$currentIP"
:log info DNS Dynamic Updated Sucessful
:log info ++++++++++++++++++++++++++++++++++
It works Very good.
Can anyone write it in MikrotikWiki?

GreetZ Da Goasler
 
puff
just joined
Posts: 1
Joined: Sun Oct 26, 2014 7:34 pm

Re: DNSDynamic Update Script

Mon Oct 27, 2014 12:08 pm

guy, can anyone prove that dnsdynamic service is still alive?
 
jetelina
newbie
Posts: 34
Joined: Thu Jun 27, 2013 11:22 pm

Re: DNSDynamic Update Script

Tue Jun 14, 2016 5:19 pm

guy, can anyone prove that dnsdynamic service is still alive?
I have come across this service and tried to register, but it looks dead. I didn't received account confirmation email.

Who is online

Users browsing this forum: No registered users and 28 guests