บทความสำหรับ: ผู้ที่มีความรู้เกี่ยวกับระบบเครือข่ายในระดับเบื้องต้นถึงปานกลาง (v1.1)
โดย วิทวัส โฉมประเสริฐ, ศุภสิทธิ์ ศิริพานิชกร
คำถาม
1.ถ้าต้องการตั้งค่าอุปกรณ์ MikroTik RB750G กับ DDNS ที่ให้บริการของ Dyndns.com ต้องตั้งค่าอย่างไรบ้าง ?
คำตอบ
บทความนี้อ้างอิงกับบทความ
1.0 วิธีติดตั้ง MikroTik RB750G เพื่อเชื่อมต่อ Internet
mikrotik.com - dynDNS Update Script
SCRIPT ที่ 1 - กำหนด Script ชื่อ "dyndns-update" โดยเรากำหนด Username. Password และ Hostname โดยเปลี่ยนตามข้อมูล DYNDNS ของเราเองได้เลยครับ
- โค้ด: เลือกทั้งหมด
# Set needed variables
:local username "dyndnsUsername"
:local password "dyndnsPassword"
:local hostname "hostname.dyndns.org"
:global dyndnsForce
:global previousIP
# print some debug info
:log info ("dyndns-update: username = $username")
:log info ("dyndns-update: password = $password")
:log info ("dyndns-update: hostname = $hostname")
:log info ("dyndns-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="members.dyndns.org" src-path="/nic/update?hostname=$hostname&myip=$currentIP" dst-path="/dyndns.txt"
:local result [/file get dyndns.txt contents]
:log info ("dyndns-update: Dyndns update needed")
:log info ("dyndns-update: Dyndns Update Result: ".$result)
:put ("Dyndns Update Result: ".$result)
} else={
:log info ("dyndns-update: No dyndns update needed")
}
SCRIPT ที่ 2 - กำหนด Script ชื่อ "dyndns-force" โดยกำหนดให้อุปกรณ์ Mikrotik ทำการ update account ทุก 24 ชั่วโมง เพื่อไม่ให้ Account (ในกรณีที่ใช้งานแบบฟรี) ไม่ถูกระงับบริการครับ
- โค้ด: เลือกทั้งหมด
:global dyndnsForce true
/system script run dyndns-update
SCHEDULERS ที่ 3 - กำหนด Script ชื่อ "schedulers" โดยเป็นการกำหนดให้อุปกรณ์ Mikrotik ทำการสั่งให้รันสคริปท์ "dyndns-update" ทุก 15 ชั่วโมง เพื่อให้ IP WAN ของ Mikrotik เป็นปัจจุบันอยู่เสมอครับ
- โค้ด: เลือกทั้งหมด
/system scheduler add comment="" disabled=no interval=15m name=dyndns-update on-event=\
dyndns-update start-date=jan/01/1970 start-time=00:00:00
/system scheduler add comment="" disabled=no interval=1d name=dyndns-force on-event=\
dyndns-force start-date=jan/01/1970 start-time=02:00:00
ดาวน์โหลด - WINBOX
ข้อมูลสินค้าแบบมัลติมีเดีย (Multimedia)
[youtube][/youtube]
จบบทความ
รายละเอียดการให้บริการจากทีมงาน SYS2U.COM Xpert Zone