Dynamic DNS - ntrits
Από AWMN-WiKi
Πίνακας περιεχομένων |
Εισαγωγή
Λόγω του ότι το DynDns δεν είναι πιά ελευθερο χωρίς συνδρομή, παραθέτω ένα script για ChangeIP, και αναδημοσιέυω από παλιότερη δημοσιέυση ένα script για DynDns για mikrotik 4.x και 5.x. για να βρίσκονται μαζεμένα (ενδεχομένως να χρειάζονται κάποιες μικρές αλλαγές για έκδοση 3.x)
Τα script είναι από το mikrotik wiki με μικρές αλλαγές.
ChangeIP Mikrotik Script
Συμπληρώνετε τα username/pass και το dns name που έχετε κάνει register στο ChangeIP
Τέλος το βάζετε να τρέχει κάθε 1 ώρα
# Set needed variables
:local user "ChangeIP Username"
:local pass "ChangeIP Password"
:local host "myhost.chanageip.com"
:global ChangeForce
:global lastIP
# print some debug info
:log info ("UpdateChangeIP: username = $user")
:log info ("UpdateChangeIP: password = $pass")
:log info ("UpdateChangeIP: hostname = $host")
:log info ("UpdateChangeIP: previousIP = $lastIP")
#Get the IP address from the internet (in case of double-nat) and parse the IP result
# more updater request details available at http://www.changeip.com/clients.asp
# Also you can use difrent ip check providers like "dynamic.zoneedit.com/checkip.html", but need to modify the script
/tool fetch mode=http address="ip.changeip.com" host="ip.changeip.com" src-path="/" dst-path="/ip.chnageip.txt"
:global result [/file get ip.chnageip.txt contents]
:local nowIP [:pick $result ([:find $result "="] +1) ([:find $result "->"] -1)]
# Remove the # on next line to force an update every single time - useful for debugging, but you could end up getting blacklisted!
#:set ChangeForce true
# Determine if ChangeIP update is needed
:if (($nowIP != $lastIP) || ($ChangeForce = true)) do={
:set ChangeForce false
:set lastIP $nowIP
/tool dns-update name=$host address=$nowIP key-name=$user key=$pass
:log info ("UpdateChangeIP: ChangeIP update needed")
} else={
:log info ("UpdateChangeIP: No ChangeIP update needed")
}
DynDns Mikrotik Script
Συμπληρώνετε τα username/pass και το dns name που έχετε κάνει register στο DynDns
Τέλος το βάζετε να τρέχει κάθε 1 ώρα
# Set needed variables
:local username "YourUsername"
:local password "YourPassword"
:local hostname "hostname.dyndns.net"
: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 available at http://www.dyndns.com/developers/specs/syntax.html
:if (($currentIP != $previousIP) || ($dyndnsForce = true)) do={
:set dyndnsForce false
:set previousIP $currentIP
/tool fetch user=$username password=$password mode=http address="members.dyndns.org" src-path="/nic/update?hostname=$hostname&myip=$currentIP" 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")
}
Afraid Dynamic DNS Mikrotik Script
Συμπληρώνετε το update string που παίρνετε από το afraid για τον Host που έχετε δημιουργήσει
Τέλος το βάζετε να τρέχει κάθε 1 ώρα
# Set needed variable
# [ Use This Part ]
#http://freedns.afraid.org/dynamic/update.php?xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
#
:local UpdateString "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
#
:global ChangeForce
:global lastIP
# print some debug info
:log info ("Previous IP = $lastIP")
#Get the IP address from the internet (in case of double-nat) and parse the IP result
# Also you can use difrent ip check providers like "dynamic.zoneedit.com/checkip.html", but need to modify the script
/tool fetch mode=http url="http://freedns.afraid.org/dynamic/check.php" dst-path="/ip.afraid.txt"
:global result [/file get ip.afraid.txt contents]
:local nowIP [:pick $result ([:find $result "Detected IP : "] +14) ([:find $result "HTTP_CLIENT"] -1)]
:log info ("Current IP = $nowIP")
# Remove the # on next line to force an update every single time - useful for debugging, but you could end up getting blacklisted!
#:set ChangeForce true
# Determine if ChangeIP update is needed
:if (($nowIP != $lastIP) || ($ChangeForce = true)) do={
:set ChangeForce false
:set lastIP $nowIP
/tool fetch mode=http url="http://freedns.afraid.org/dynamic/update.php\?$UpdateString" dst-path="/res.afraid.txt"
:log info [/file get res.afraid.txt contents]
:log info ("UpdateChangeIP: ChangeIP update needed")
} else={
:log info ("UpdateChangeIP: No ChangeIP update needed")
}
--NetTraptor 17:37, 16 Ιανουαρίου 2012 (EET)

