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

  • สคริปสำหรับ DDNS ตัวใหม่ครับ
    เริ่มโดย wong62
    Read 48,392 times
0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

 

 
สำหรับผู้ที่เจอปัญหาเรื่อง ddns ครับสำหรับ เว็บนี้ฟรี 100% (DNSdynamic will always be absolutely free.)
สมัครได้ที่นี่ครับ http://www.dnsdynamic.org/

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


# DDNS control automatic updates
# Set needed variables
:local username "Username"
:local password "Password"
:local hostname "Host Name"

:global dyndnsForce
:global previousIP

# print some debug info
#:log info ("IPddns-update: username = $username")
#:log info ("IPddns-update: password = $password")
#:log info ("IPddns-update: hostname = $hostname")
#:log info ("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=https address="www.dnsdynamic.org" src-path="/api/?hostname=$hostname&myip=$currentIP"
   :local result [/file get dyndns.txt contents]
   :log info ("IPddns-update: IPddns update needed")
   :log info ("IPddns-update: IPddns Update Result: ".$result)
   :put ("No-IPddns Update Result: ".$result)
} else={
   :log info ("IPddns-update: No IPddns update needed")
}
}



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

# Set needed variables
:local ddnsuser "Username"
:local ddnspass "Password"
:local theinterface "Wan Interface"
:local ddnshost "Host Name"

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

yod


ขอบคุณมากๆเลยครับพี่

หายไปนานเลย แต่มาที มีของมาแจกด้วย  ;D ;D ;D

ขอบคุณมากครับพี่ ip ไม่ยอม update ใน dyndns.com เลย วันนี้ขอเอาอันนี้ไปลองนะครับ ได้ผลยังไง เดี๋ยวมาแชร์ครับ  :)


ของ DynDNS ผมใช้สคริปตามเวอร์ชั่นของ RouterOS ใน http://wiki.mikrotik.com/wiki/Dynamic_DNS_Update_Script_for_dynDNS ก็ใช้ได้ปกติดีนะครับ

ถ้าใช้ตัวฟรี (ที่สมัครไว้ตั้งแต่มันยังเปิดฟรีอยู่) Dynamic Host จะถูกลบออกบ่อยครับ ต้องเข้าไป Add ใหม่เรื่อยๆ
ผมเลยสมัครตัวเสียเงิน ไม่มีปัญหาเลยครับ ใช้ได้ดีมากๆ

สรุปว่า มันไม่ยอม update ไปที่เว็บ ddns อยู่ดีครับ ตอนนี้มึน ไม่รู้จะทำยังไง ใน mikrotik มี script ทั้งของ dyndns กับ dynamicdns แต่ไม่อัพเดทซักตัว  ???

yod


โดนแบนหรือเปล่าครับ หรือ ปรับเวลา NTP ถูกต้องมั้ยครับ

ผมเองก็ใช้อยู่น่ะ ทำ VPN ระหว่างบ้านกะที่ร้าน ใช้ Mikrotik 2 ตัว และใช้ Dynamic DNS ของ dyndns.org

#6
ครับ ตอนนี้ก็ยังลองผิด ลองถูกไปเรื่อยครับ แต่ได้ความช่วยเหลือจากคุณ tOn— กับคุณ yuttapong แล้ว ไม่แน่รอบนี้สคริปต์อาจจะเวิร์คครับ ต้องรอ ip มันเปลี่ยนก่อนน่ะครับ (ไม่กล้ากด reboot Router ครับ เพราะโทรศัพท์จะดังต่อเนื่องไม่หยุดทันทีที่เน็ตใช้ไม่ได้ 555)

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

เรื่องเวลาใน NTP ผมเข้าใจว่า ผมน่าจะทำแล้วครับ เพราะกดเข้าไปดูใน Clock กี่ทีๆ เวลาก็ตรงนะครับ  :)

ได้แล้วนะครับพี่ยอด ได้ความช่วยเหลือจากคุณ yuttapong สคริปต์ ddns ก็เลยทำงานตลอดแล้วครับ ขอบคุณมากครับ



คุณ ยอดครับ ลองเทส ทั้งสอง สคลิป แล้วครับ ไม่ยอมอัพเดทให้ครับ  

yod
น่าจะใช้ไม่ได้กับ firmware ตัวใหม่แล้วอะครับ เดี๋ยวผมลองหาดูให้ใหม่นะครับ