Sysnet Board คู่มือ การใช้งานอุปกรณ์ Network

การ Config อุปกรณ์ เครือข่าย Network Device => อุปกรณ์ Mikrotik Router => หัวข้อที่ตั้งโดย: wong62 เมื่อ วันที่ 20 มีนาคม 2014, 00:44:01

ชื่อ: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: wong62 เมื่อ วันที่ 20 มีนาคม 2014, 00:44:01
สำหรับผู้ที่เจอปัญหาเรื่อง ddns ครับสำหรับ เว็บนี้ฟรี 100% (DNSdynamic will always be absolutely free.)
สมัครได้ที่นี่ครับ http://www.dnsdynamic.org/ (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 (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";
   }
}
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: yod เมื่อ วันที่ 20 มีนาคม 2014, 13:43:23


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

หายไปนานเลย แต่มาที มีของมาแจกด้วย  ;D ;D ;D
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: mobilesuit เมื่อ วันที่ 26 มีนาคม 2014, 17:22:02
ขอบคุณมากครับพี่ ip ไม่ยอม update ใน dyndns.com เลย วันนี้ขอเอาอันนี้ไปลองนะครับ ได้ผลยังไง เดี๋ยวมาแชร์ครับ  :)
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: Mr.Zenith เมื่อ วันที่ 27 มีนาคม 2014, 20:38:58

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

ถ้าใช้ตัวฟรี (ที่สมัครไว้ตั้งแต่มันยังเปิดฟรีอยู่) Dynamic Host จะถูกลบออกบ่อยครับ ต้องเข้าไป Add ใหม่เรื่อยๆ
ผมเลยสมัครตัวเสียเงิน ไม่มีปัญหาเลยครับ ใช้ได้ดีมากๆ
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: mobilesuit เมื่อ วันที่ 28 มีนาคม 2014, 14:06:35
สรุปว่า มันไม่ยอม update ไปที่เว็บ ddns อยู่ดีครับ ตอนนี้มึน ไม่รู้จะทำยังไง ใน mikrotik มี script ทั้งของ dyndns กับ dynamicdns แต่ไม่อัพเดทซักตัว  ???
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: yod เมื่อ วันที่ 28 มีนาคม 2014, 15:04:14


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

ผมเองก็ใช้อยู่น่ะ ทำ VPN ระหว่างบ้านกะที่ร้าน ใช้ Mikrotik 2 ตัว และใช้ Dynamic DNS ของ dyndns.org
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: mobilesuit เมื่อ วันที่ 29 มีนาคม 2014, 23:55:57
ครับ ตอนนี้ก็ยังลองผิด ลองถูกไปเรื่อยครับ แต่ได้ความช่วยเหลือจากคุณ tOn— กับคุณ yuttapong แล้ว ไม่แน่รอบนี้สคริปต์อาจจะเวิร์คครับ ต้องรอ ip มันเปลี่ยนก่อนน่ะครับ (ไม่กล้ากด reboot Router ครับ เพราะโทรศัพท์จะดังต่อเนื่องไม่หยุดทันทีที่เน็ตใช้ไม่ได้ 555)

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

เรื่องเวลาใน NTP ผมเข้าใจว่า ผมน่าจะทำแล้วครับ เพราะกดเข้าไปดูใน Clock กี่ทีๆ เวลาก็ตรงนะครับ  :)
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: mobilesuit เมื่อ วันที่ 31 มีนาคม 2014, 16:13:32
ได้แล้วนะครับพี่ยอด ได้ความช่วยเหลือจากคุณ yuttapong สคริปต์ ddns ก็เลยทำงานตลอดแล้วครับ ขอบคุณมากครับ
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: yuttapong เมื่อ วันที่ 14 พฤษภาคม 2014, 16:45:58


คุณ ยอดครับ ลองเทส ทั้งสอง สคลิป แล้วครับ ไม่ยอมอัพเดทให้ครับ  
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: yod เมื่อ วันที่ 14 พฤษภาคม 2014, 18:07:53
น่าจะใช้ไม่ได้กับ firmware ตัวใหม่แล้วอะครับ เดี๋ยวผมลองหาดูให้ใหม่นะครับ
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: yuttapong เมื่อ วันที่ 14 พฤษภาคม 2014, 18:17:20
ครับ ขอบคุณครับ
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: tawatchai_mwf เมื่อ วันที่ 3 กรกฎาคม 2014, 22:11:09
ขอความช่วยเหลือครับ...ผมไม่สามารถ Set Dynanic DNS ลงบน Mikrotik ได้ครับ ผบลองทุกเวอร์ชั่นแล้วครับ ไม่ทราบผมผิดขั้นตอนไหนครับ ผมทำตามคำแนะนำในเว็บแล้วครับ
ขอคำแนะนำด้วยครับ มือใหม่ครับ

ขอบคุณครับ
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: yuttapong เมื่อ วันที่ 4 กรกฎาคม 2014, 10:30:49

ลองทำตามหัวข้อนี้หรือยังครับ  ตอนนี้ host ของ no-ip ใช้ได้ปกติแล้วครับ
https://www.sysnetcenter.com/board/index.php/topic,991.0/ (https://www.sysnetcenter.com/board/index.php/topic,991.0/)
แต่ถ้าไม่อยากเขียนสคลิป ก็อัพเป็น V6.14 ขึ้นไปครับ จะมี Dynamic DNS ให้ครับ ทำตามหัวข้อนี้ได้เลยครับ
https://www.sysnetcenter.com/board/index.php?topic=2581.0 (https://www.sysnetcenter.com/board/index.php?topic=2581.0)
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: yod เมื่อ วันที่ 4 กรกฎาคม 2014, 12:33:42


ผิดตรงขั้นตอนไหนครับ
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: tawatchai_mwf เมื่อ วันที่ 4 กรกฎาคม 2014, 19:59:03
ขอบคุณมากครับ คุณ ยุทธพงษ์ สำหรับคำแนะนำดีๆ
 แต่ผมได้สมัคร Dyndns รายปีไวัแล้ว ผมอยากใช้ตัวนี้ ผมต้องทำอย่างไรบ้างครับ

ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: tawatchai_mwf เมื่อ วันที่ 4 กรกฎาคม 2014, 20:04:54
สวัสดีครับคุณ ยอด
  ผมรบกวนคุณยอดช่วยแนะนำการวางสคริปสำหรับ DDNS ตัวใหม่ให้ผมสักหน่อยได้มั้ยครับ ผมมือใหม่มากครับ แต่ใจรักทางนี้ครับ

ขอบคุณล่วงหน้าไว้ณ.ที่นี้ครับ
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: yod เมื่อ วันที่ 4 กรกฎาคม 2014, 20:47:30
ไม่แน่ใจว่าเหมือนของเดิมหรือเปล่า ผมเปลี่ยนไปมาเพราะชนกับตัวแปลที่เป็น global ของ script อันอื่น แต่ใช้งานได้แน่นอนครับ เพราะผมใช้อยู่ ทำ vpn ระหว่างบ้านกับที่ร้านในเซียร์

เปลี่ยนตรง xxxx ครับ


# Set needed variables
:local username "xxxx"
:local password "xxxx"
:local hostname "xxxx"

:global AdyndnsForce
:global ApreviousIP

# print some debug info
#:log info ("UpdateDynDNS: username = $username")
#:log info ("UpdateDynDNS: password = $password")
#:log info ("UpdateDynDNS: hostname = $hostname")
#:log info ("UpdateDynDNS: ApreviousIP = $ApreviousIP")

# 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"
:delay 1
: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]
#:local currentIP get [/ip address find interface=pppoe-out1]
: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 AdyndnsForce true

# Determine if dyndns update is needed
# more dyndns updater request details http://www.dyndns.com/developers/specs/syntax.html

:if (($currentIP != $ApreviousIP) || ($AdyndnsForce = true)) do={
  :set AdyndnsForce false
  :set ApreviousIP $currentIP
  :log info "$currentIP or $ApreviousIP"
  /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"
  :delay 1
  :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")
}
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: tawatchai_mwf เมื่อ วันที่ 5 กรกฎาคม 2014, 12:08:29
คุณ ยอด ครับ

ผมได้ลองเอาสคริปตัวใหม่ใหม่ที่คุณยอดให้มา แล้วทำตามขั้นตอนของหัวข้อ " การ Set Dynanic DNS บน Mikrotik โดยใช้ Service DynDNS.org " ได้ลองเข้าดูใน dyndns.com ค่า IP Address ไม่ตรงกันครับ ผมผิดขั้นตอนไหนครับ มีคำแนะนำเพิ่มเติมมั๊ยครับ ผมแนบรูปมาด้วยครับ

ขอบคุณมากครับ
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: yod เมื่อ วันที่ 5 กรกฎาคม 2014, 14:06:19


ฝั่งขา wan ของ Mikrotik เป็น IP อะไรครับ
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: tawatchai_mwf เมื่อ วันที่ 5 กรกฎาคม 2014, 23:04:30
คุณ ยอดครับ

ณ. ตอนนี้ IP Address 115.87.115.7 ครับ
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: tawatchai_mwf เมื่อ วันที่ 6 กรกฎาคม 2014, 15:23:27
คุณยอดครับ
ผมยังคงติดปัญหา IP Address ขาเข้า Wan RB450G ไม่ตรงกับ IP Address ของ dyndns ที่สมัครไว้ครับ ขอความช่วยเหลือด้วยครับ ผมลองมาหลายวันแล้วครับ ผมไม่แน่ใจผมผิดขั้นตอนไหนบ้างครับ ผมขอรบกวนคุณยอดช่วยอธิบายขั้นตอนการเซตอัพและการตรวจเช็คปัญหาด้วยครับ

ขอบคุณล่วงหน้าไว้ณ.ที่นี้ด้วยครับ
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: yod เมื่อ วันที่ 6 กรกฎาคม 2014, 16:45:49


คือในนี้ผมก็เขียนไว้ละเอียดมากแล้วนะครับ

การ Set Dynanic DNS บน RouterOS โดยใช้ Service DynDNS.org
https://www.sysnetcenter.com/board/index.php/topic,421.0/ (https://www.sysnetcenter.com/board/index.php/topic,421.0/)

ตรวจสอบเวลาตรงหรือไม่?
จำนวน run ของ script มีเพิ่มขึ้นหรือไม่?
user/password, hostname ถูกต้องหรือไม่?

ถ้ายังใช้ไม่ได้ แนะนำเป็น dynamic dns ของ mikrotik โดยตรงครับ จะได้ไม่ต้องเสียเวลา

https://www.sysnetcenter.com/board/index.php?topic=2581.0 (https://www.sysnetcenter.com/board/index.php?topic=2581.0)
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: tawatchai_mwf เมื่อ วันที่ 20 กรกฎาคม 2014, 19:41:30
คุณยอดครับ
dyndns ที่ผมสมัครใช้งานได้แล้วครับ จากสคริปที่คุณยอดส่งมาให้ใหม่พร้อมคำแนะนำ

ขอบคุณมากครับ ขอบคุณอีกครั้งจากใจ
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: tawatchai_mwf เมื่อ วันที่ 21 กรกฎาคม 2014, 19:48:09
คุณยอดครับ
ผมขอความช่วยเหลืออีกนิดครับ คือ dyndns ไม่อัพเดตครับ อัพเดตเวลาผมเช็คแล้วครับโอเค ทุกครั้งที่ผม Reboot ผมต้องกดรันสคริปใหม่ทุกครั้ง ผมถึงจะรีโมทเข้ามาได้ ขอความช่วยเหลือด้วยครับ

ขอบคุณล่วงหน้ามาณ.ที่นี้ครับ
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: yod เมื่อ วันที่ 21 กรกฎาคม 2014, 20:16:43


ตั้ง system --> schedule หรือยังครับ
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: tawatchai_mwf เมื่อ วันที่ 22 กรกฎาคม 2014, 09:55:31
คุณยอดครับ
ผมได้เข้าไปเช็ค System --> Scheduler แล้วครับ มันขึ้นเองครับ (ผมได้แนบรูปมาด้วยครับ)แต่ถ้าจะตั้งจะต้องกำหนดค่าอะไรและอย่างไรบ้างครับ

ขอบคุณล่วงหน้าด้วยครับ
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: tawatchai_mwf เมื่อ วันที่ 23 กรกฎาคม 2014, 16:43:23
คุณยอดครับ
dyndns ผมอัพเดตได้แล้วครับ ขอบคุณมากครับสำหรับข้อมูลและคำแนะนำ

ขอบคุณครับ
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: yod เมื่อ วันที่ 23 กรกฎาคม 2014, 20:12:20


ใช้ mikrotik clound

work กว่าเยอะครับ  ;D
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: tawatchai_mwf เมื่อ วันที่ 24 กรกฎาคม 2014, 18:31:43
คุณยอดครับ

ขอคำแนะนำการใช้ mikrotik cloud ด้วยครับ อยากใช้บ้างครับ

ขอบคุณครับ
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: yod เมื่อ วันที่ 25 กรกฎาคม 2014, 13:17:41


Link นี้ครับ

https://www.sysnetcenter.com/board/index.php?topic=2581.0/ (https://www.sysnetcenter.com/board/index.php?topic=2581.0/)
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: tawatchai_mwf เมื่อ วันที่ 27 กรกฎาคม 2014, 10:24:01
คุณยอด

ขอบคุณมากครับสำหรับคำแนะนำ
ชื่อ: Re: สคริปสำหรับ DDNS ตัวใหม่ครับ
โดย: eak9599 เมื่อ วันที่ 25 กันยายน 2017, 19:56:43


สคริปตัวนี้แก้เป็นของ THDDNS ของ AISFIBER ได้ไหมครับ