Welcome to Sysnet Board คู่มือ การใช้งานอุปกรณ์ Network. Please log in or sign up.
สมาชิกทั้งหมด
17,600
กระทู้ทั้งหมด
10,031
หัวข้อทั้งหมด
4,714

  • Re: รบกวนหน่อยครับ no-ip ด้วย mikrotik
    เริ่มโดย yuttapong
    Read 11,213 times
0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

 

 
คือสคลิป ที่เขียนเพื่ออัพเดทไปยัง no-ip อะครับ คือไม่ยอมซิ้งกับ no-ip เวลาเข้าไปเช็คใน no-ip ยังเป็นไอพีเดิมอยู่เลยครับ(โฮส ไดนามิกไอพี) แต่ไปเช็คไอพีเรา คนละไอพีกันครับ เพราะมันไม่ยอมอัพเดทให้ครับ


แล้วถ้าเราต้องการรีโมตจากโฮสไดนามิกไอพี ให้ forword มาที่เครื่องเราต้องทำยังไงบ้างครับ กำหนดใน nat แล้วไม่ผ่านครับ มันให้กำหนดเป็นไอพี แต่ถ้าเรารีเราเตอร์ไอพีก็จะเปลี่ยนอะครับ อยากให้ไอพีเปลี่ยนตามด้วยครับ

yod


ตั้ง schedule ไว้หรือยังครับ copy จากหัวข้อ dyndns ได้เลยครับ แต่เปลี่ยนชื่อให้ตรงกับชื่อ script ที่ตั้งไว้ครับ และเวลาต้อง update ให้ตรงด้วยนะครับ แต่ปกติผมจะตั้ง ntp client และ clock ไว้ให้แล้วครับ

#2
# No-ip DNS control automatic updates
# Information on no-ip.com account
: global usernoip "xxx"
: global passnoip "xxx"
: global hostnamenoip "hostno-ip"
# Edit variable over here

: global previousIP

# Print the log to debug
: log info "DNSNoIP: Updating dynamic IP on DNS for host $ hostnamenoip"
: log info "DNSNoIP: Pass $ passnoip"
: log info "DNSNoIP: Last IP $ previousIP"

# Get the public IP on the intenet, you can also if you have a PHP script hosting support PHP
/ tool fetch mode = "http" address = "checkip.dyndns.org" src-path = "/" dst-path = "/ ddnsnoip.html"

: local results [/ file get contents ddnsnoip.html]

# Edit to get the latest IP
: local hasilLen [: len $ result]
: local startLoc [: find $ result ":" -1]
: set startLoc ($ startLoc 2)
: local endLoc [: find $ result "</ body>" -1]
: global currentIP [: pick $ result $ startLoc $ endLoc]
: log info "DNSNoIP: IP is now $ currentIP"

# Preparation update
: local str "/ nic / update? hostname = $ hostnamenoip & myip = $ currentIP"

: if ($ currentIP! = $ previousIP) do = {
: log info "DNSNoIP: Required Update"
: set previousIP $ currentIP
: log info "DNSNoIP: Send Update $ currentIP"
: log info [: put [/ tool fetch user = "$ usernoip" password = "$ passnoip" mode = "http" address = "dynupdate.no-ip.com" src-path = "$ str" dst-path = "/ $ hostnamenoip"]]
: log info "DNSNameCheap: Host $ hostnamenoip been updated in DNSNoIP with IP $ currentIP"
=} Else {
: log info "DNSNoIP: $ previousIP previous IP and IP are now $ currentIP same, no update needed"
}

โค๊ดที่ผมทำอะครับ ใน schedule ผมก็ทำตามแล้วให้รันทุก20 นาที แต่ก็ไม่ได้ครับ ใน no-ip ไม่ยอมอัพเดทให้ครับ(ในเวป)

สคริปที่ใช้ผิดครับที่ถูกต้องอันนี้

# No-ip DNS control automatic updates
# Set needed variables
:local username "No-IP Username"
:local password "No-IP Password"
:local hostname "Your No-IP Hostname"

:global dyndnsForce
:global previousIP

# print some debug info
#:log info ("No-IPddns-update: username = $username")
#:log info ("No-IPddns-update: password = $password")
#:log info ("No-IPddns-update: hostname = $hostname")
#:log info ("No-IPddns-update: 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 "dyndns-update: currentIP = $currentIP"

# 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="dynupdate.no-ip.com" src-path="/nic/update?hostname=$hostname&myip=$currentIP"
    :local result [/file get dyndns.txt contents]
    :log info ("No-IPddns-update: No-IPddns update needed")
    :log info ("No-IPddns-update: No-IPddns Update Result: ".$result)
    :put ("No-IPddns Update Result: ".$result)
} else={
    :log info ("No-IPddns-update: No No-IPddns update needed")
}

สคลิปนี้ก็ไม่อัพเดทอะคับ ลองแล้วครับ หรือว่าผมต้องไปแก้ตรงไหน 

เวลา copy script แล้ว copy ไม่หมดครับลองเปรียบเทียบกับต้นฉบับดูว่าท่านผิดพลาดตรงไหน เห็นมีผิดหลายที่เลย

มี 2 สคริป เลือกเอาตามใจเลยครับ

No-IP DDNS update behide nat
กรณีใช้ Mikrotik ต่อหลัง Load Balance หรือ Router ใช้สคริปนี้

# No-ip DNS control automatic updates
# Set needed variables
:local username "No-IP Username"
:local password "No-IP Password"
:local hostname "Your No-IP Hostname"

:global dyndnsForce
:global previousIP

# print some debug info
#:log info ("No-IPddns-update: username = $username")
#:log info ("No-IPddns-update: password = $password")
#:log info ("No-IPddns-update: hostname = $hostname")
#:log info ("No-IPddns-update: 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 "dyndns-update: currentIP = $currentIP"

# 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="dynupdate.no-ip.com" src-path="/nic/update?hostname=$hostname&myip=$currentIP"
    :local result [/file get dyndns.txt contents]
    :log info ("No-IPddns-update: No-IPddns update needed")
    :log info ("No-IPddns-update: No-IPddns Update Result: ".$result)
    :put ("No-IPddns Update Result: ".$result)
} else={
    :log info ("No-IPddns-update: No No-IPddns update needed")
}
}


สำหรับต้องการระบุ out-interface

# Set needed variables
:local ddnsuser "username"
:local ddnspass "password"
:local theinterface "interface"
:local ddnshost "hostname.no-ip.org"

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

yod
ขอบคุณมากครับพี่กฤษฏา  ;D ;D ;D

ได้แล้วครับ ขอบคุณมากๆ ครับ