ตั้งกระทู้ปุ๊บมีลูกค้าถามมาปั๊บ :D :D :D
"ยอด แล้วถ้าพี่จะให้มันส่งเมล์มาละจะทำยังไง พี่ไม่มี mail server น่ะ"
ถ้าพี่ไม่มี mail server เป็นของตัวเอง พี่ก็ใช้ของชาวบ้านเลยครับ เช่น gmail มันจะให้พี่ใช้ smtp ได้ น่าจะวันนึงให้ส่งได้ไม่เกิน 50-100 ฉบับ
สมัคร gmail account ให้เรียบร้อยก่อนครับ
เข้า Winbox --> Tool --> Email
Server: 173.194.69.109 (เป็น Mail Server ของ gMail)
Port: 587
From: ชื่อ gmail ที่สมัครไว้
User: ชื่อ gmail ที่สมัครไว้
Password: : password ของ gmail ที่สมัครไว้
(https://www.sysnetcenter.com/board/images/routerboard/tool-fetch/mikrotik-up-wan-ip-05.jpg)
Click [OK]
จากนั้นแก้ Script ด้านล่างตรงตัวสีแดง ให้ตรงกับ gmail ที่ใช้งานครับ จะเป็นการใช้ tool ในการส่ง email ของ mikrotik จะสามารถ attatch file ได้
ส่วน body ผมไม่ได้ใช้ครับ อ่านแค่ subject ก็พอแล้ว ;D ;D
#ประกาศตัวแปลเป็น global เพื่อให้ค่าที่อยู่ในตัวแปลไม่หายไปเมื่อ run script เสร็จ
:global previousIP
# อ่านค่า Wan IP จาก checkip.dyndns.org ซึ่งในกรณีที่ Routerboard ต่ออยู่หลัง Router อีกที
/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]
: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 "Current wan ip: currentIP = $currentIP"
#ตรวจสอบ Wan IP ว่ามีการเปลี่ยนแปลงหรือไม่ ถ้าไม่ก็จะไม่ทำคำสั่งต่อ
:if ($currentIP != $previousIP) do={
:set previousIP $currentIP
/tool e-mail send to="เมล์ที่จะส่งเข้า" password=gmail-password subject=([/system clock get date]." Zeer Wan IP: ".$currentIP) from=gmail ที่สมัครไว้ server=173.194.69.109 tls=yes
:delay 1
:log info ("Update wan ip successfully..")
}
ถ้าให้ RouterBoard เป็น Gateway ออก Internet โดยตรง เช่น PPPoE
<< Internet >>=======<< Modem (Bridge Mode) >>=======<< RouterBoard (PPPoE) >>
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++#
#ประกาศตัวแปลเป็น global เพื่อให้ค่าที่อยู่ในตัวแปลไม่หายไปเมื่อ run script เสร็จ
:global previousIP
:local currentIP [/ip address get [find interface="pppoe-out1"] address];
:log info "Current wan ip: currentIP = $currentIP"
#ตรวจสอบ Wan IP ว่ามีการเปลี่ยนแปลงหรือไม่ ถ้าไม่ก็จะไม่ทำคำสั่งต่อ
:if ($currentIP != $previousIP) do={
:set previousIP $currentIP
/tool e-mail send to="เมล์ที่จะส่งเข้า" password=gmail-password subject=([/system clock get date]." Zeer Wan IP: ".$currentIP) from=gmail ที่สมัครไว้ server=173.194.69.109 tls=yes
:delay 1
:log info ("Update wan ip successfully..")
}
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++#
ทดสอบ Run Script ครับ
(https://www.sysnetcenter.com/board/images/routerboard/tool-fetch/mikrotik-up-wan-ip-06.jpg)
เรียบร้อย
อยากได้แบบเช็ค ip อ่าครับ
Users found this pages searching for: