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

  • การ Set Dynanic DNS บน Mikrotik โดยใช้ Service No-IP
    เริ่มโดย wong62
    Read 32,207 times
0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

 

 

การ Set Dynanic DNS บน Mikrotik โดยใช้ Service No-IP



ยังไม่ได้ทดสอบนะครับ ใครว่างช่วยลองทดสอบให้ด้วย
แก้ไขแล้วครับ อันเดิมมันไม่ผ่าน ตัวนี้ทดลองแล้ว กับ V.5 (โมจากสคริปของ DynDNS)




# 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

แก้ไขใหม่แล้วครับอันเดิมทดลองแล้วไม่ได้ เลยลองทำเองเล่นๆ กับสคริปเดิมๆของ DynDNS ครับผมว่าสามารถใช้กับ DDNS ค่ายอื่นๆ ก็น่าจะได้นะถ้ารู้ code 
code No-IP

http://username:password@dynupdate.no-ip.com/nic/update?hostname=mytest.testdomain.com&myip=1.2.3.4

#3
เทสกับ V.4 ครับ



อันนี้เป็น V.5



เพิ่มเติมสคริปครับ อันนี้เหมาะกับผู้ที่มีเน็ตหลายเส้นครับ มันจะสลับเส้นทางให้โดยอัตโนมัติ ในกรณีที่เน็ตเส้นใดเส้นหนึ่งมีปัญหา
ไม่ต้องงงนะครับ มันใช้ dyndns เป็นตัวเช็ค current IP ของเรา



# No-ip DNS control automatic updates
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# EDIT YOUR DETAILS / CONFIGURATION HERE
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:local username "No-IP Username"
:local password "No-IP Password"
:local hostname "Your No-IP Hostname"
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# END OF USER DEFINED CONFIGURATION
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

: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")
}
}

yod
Work ครับพี่  ;D ;D


ใช้แทน dyndns ได้เลยครับ





ขอบคุณครับ




ทำไหมของผมมันขึ้นแบบนี้ครับ เป็นipของmikrotik


yod


ใช้ script อันนี้นะครับ

# No-ip DNS control automatic updates
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# EDIT YOUR DETAILS / CONFIGURATION HERE
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:local username "No-IP Username"
:local password "No-IP Password"
:local hostname "Your No-IP Hostname"
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# END OF USER DEFINED CONFIGURATION
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

: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")
}
}



ทำได้แล้วครับ
การใช้ script นี้สำหรับกรณี ต่อแบบ static wan mikrotik โดยใช้ no-ip

ขอบคุณมากครับ