Script dyndns Telkom Speedy Mikrotik bridge mode


Speedy paket familia menggunakan ip dynamic,jadi biar mikrotik bisa diremote dari luar maka mikrotik disetup autoupdate ke dyndns.com.. Mikrotik yg digunakan seri RB750 dengan OSv4.6(also work on OS v5.14) bridge mode(Dial dari mikrotik)

1. Add script:
Via Winbox: System => Scripts => Klik tanda + => Beri nama script sesuai keinginan => Centang semua Policy => Masukkan script dibawah ini => Klik Apply => Klik OK

:local ddnsuser "dyndns-login"
:local ddnspass "dyndns-password"
:local theinterface "speedy"
:local ddnshost "your.dyndnsdomain.com"
:local ipddns [:resolve $ddnshost];
:local ipfresh [ /ip address get [/ip address find interface=$theinterface ] address ]
:if ([ :typeof $ipfresh ] = nil ) do={
 :log info ("DynDNS: 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 ("DynDNS: IP-DynDNS = $ipddns")
 :log info ("DynDNS: IP-Fresh = $ipfresh")
 :log info "DynDNS: Update IP needed, Sending UPDATE...!"
 :local str "/nic/update?hostname=$ddnshost&myip=$ipfresh&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"
 /tool fetch address=members.dyndns.org src-path=$str mode=http user=$ddnsuser \
 password=$ddnspass dst-path=("/DynDNS.".$ddnshost)
 :delay 1
 :local str [/file find name="DynDNS.$ddnshost"];
 /file remove $str
 :global ipddns $ipfresh
 :log info "DynDNS: IP updated to $ipfresh!"
 } else={
 :log info "DynDNS: dont need changes";
 }
}

 
Script lain yang sukses(Tes di RouterOS v5.14):

# Set needed variables
:local username "dyndns-login"
:local password "dyndns-password"
:local hostname "your.dyndns-domain.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 "</body>" -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")
}

2. Add Scheduler:
Via Winbox:

System => Scheduler => Klik + => Masukkan parameter2 seperti gambar dibawah => Klik OK

Schedule via Terminal:

/system scheduler
add comment="" disabled=no interval=15m name=dyndns-update on-event=\
"/system script run dyndns-update" policy=\
ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive \
start-time=startup

3. Testing: Reboot mikrotik => Cek Log

 
Referensi:
http://wiki.mikrotik.com/wiki/Dynamic_DNS_Update_Script_for_dynDNS

Leave a Reply

Your email address will not be published. Required fields are marked *