PLS HLP > Updating DYN.com DDNS IP's - from PPPoE Interfaces

Hi there guys/gals...

PLEASE can an AWESOME guru (out there) help a "noop" attempt to figure out a WORKING script on my rb493G - rOS ver 5.9 ... Ihave checked out forums all over the place, with INFO overload - DAZED and CONFUSED!! - I am GETTING nowhere trying to find a WORKING script to update my ADSL/LINE(s) dynamic ip addresses (ddns) info and send it on to http://www.DYN.com...

Trying to find/develop/borrow a script where:

  • instead of determining the EXTERNAL/PUBLIC IP address - for my various Internet Connections (@ 0.0.0.0/.0) - by using "http://checkip.dyndns.org" etc

RATHER get/attain the dynamic ip address from several (3) ADSL (PPPoE dialup) interfaces- that connect our network to the Internet over different PSTN/ADSL lines.

EG/ie:
1 X international traffic - (ADSL Line3)
1 X Local VPN traffic - (ADSL Line3)
1 X Local VoIP traffic.. (ADSL Line3)

Thus I need to figure out each ip address per PPPoE connection (checking every 10-15 mins) >> then update my DYN standard service - - - host names...

EG/ie:
ADSL-1 >> PPPoE ->> IP address 196.25.1.123
ADSL-2 >> PPPoE ->> IP address 41.25.1.123
ADSL-3 >> PPPoE ->> IP address 196.1.3.123

Then have a script to send these IP addresses to DYN.com as
ADSL-1.dumbass.com >> A RECORD >> IP address 196.25.1.123
ADSL-2.dumbass.com >> A RECORD >> IP address 41.25.1.123
ADSL-3.dumbass.com >> A RECORD >> IP address 196.1.3.123

Currently with my extremely limited scripting abilities I have managed to find/work on two scripts -

PLEASE can someone make this easier for me?

SCRIPT 1 >>>>

# Set needed variables
:local username "noob"
:local password "XXXXXX"
:local hostname "iADSL-1.dumbass.com"

:global dyndnsForce
:global previousIP

print some debug info

:log info ("UpdateDynDNS: username = $username")
:log info ("UpdateDynDNS: password = $password")
:log info ("UpdateDynDNS: hostname = $hostname")
:log info ("UpdateDynDNS: previousIP = $previousIP")

get the current IP address from the internet (in case of double-nat)

/tool fetch mode=http address="checkip.dyndns.org" src-path="/" dst-path="/dyndns.checkip.html"
:local result [/file get dyndns.checkip.html contents]

parse the current IP result

:local resultLen [:len $result]
:local startLoc [:find $result ": " -1]
:set startLoc ($startLoc + 2)
:local endLoc [:find $result "" -1]
:local currentIP [:pick $result $startLoc $endLoc]
:log info "UpdateDynDNS: currentIP = $currentIP"

Remove the # on next line to force an update every single time - useful for debugging,

but you could end up getting blacklisted by DynDNS!

#:set dyndnsForce true

Determine if dyndns update is needed

more dyndns updater request details http://www.dyndns.com/developers/specs/syntax.html

:if (($currentIP != $previousIP) || ($dyndnsForce = true)) do={
:set dyndnsForce false
:set previousIP $currentIP
:log info "$currentIP or $previousIP"
/tool fetch user=$username password=$password mode=http address="members.dyndns.org"
src-path="nic/update?system=dyndns&hostname=$hostname&myip=$currentIP&wildcard=no"
dst-path="/dyndns.txt"
:local result [/file get dyndns.txt contents]
:log info ("UpdateDynDNS: Dyndns update needed")
:log info ("UpdateDynDNS: Dyndns Update Result: ".$result)
:put ("Dyndns Update Result: ".$result)
} else={
:log info ("UpdateDynDNS: No dyndns update needed")
}

SCRIPT 2 >>>>

# Dynamic DNS Update / Simple Edition
:global pppoeinterfacename "ADSL-1"
:global pppoednsname "ADSL-1.dumbass.com"
:global pppoednsip [:resolve $pppoednsname]
:global currentip [/interface pppoe-client get $ppoeinterfacename connect-to]
:if ($currentip != $pppoednsip) do={ /interface pppoe-client set [find name=$pppoeinterfacename] connect-to=$pppoednsip}
}

Any/ALL assistance would be greatly appreciated..... :smiley: :open_mouth: :laughing:

Cheers & thanks

anthony@zeane.com

Here is another script that may be of some use:
http://wiki.mikrotik.com/wiki/Dynamic_DNS_Update_Script_for_ChangeIP.com

In particular, in your script change

# get the current IP address from the internet (in case of double-nat)
/tool fetch mode=http address="checkip.dyndns.org" src-path="/" dst-path="/dyndns.checkip.html"
:local result [/file get dyndns.checkip.html contents]

# parse the current IP result
:local resultLen [:len $result]
:local startLoc [:find $result ": " -1]
:set startLoc ($startLoc + 2)
:local endLoc [:find $result "</body>" -1]
:local currentIP [:pick $result $startLoc $endLoc]

to

# get the current IP address
:local currentIP [ /ip address get [/ip address find interface=<PPPoE Client Interface Name>] address ]

From there you will need to do a little tweaking to either have it run 3 different times, or copy the script three times and change the appropriate global variables so they don’t stomp all over each other, but it’s a start.

THANK YOU VERY much… So do I combine the two scripts into one, with your suggested changes??? How best to do this >>> No not lazy, just a bit brain-dead and getting old and grey with this issue.. LOL - just asking your EXPERT suggestion… THX