Mikrotik Send IP TO EMAIL V.2
พอดีมีลักษณะงานที่ลูกค้าถามมาแบบนี้ครับ
ลูกค้าใช้เนต 2 wan เซตเป็น static ทั้งสองเส้น
ether1=192.168.1.2 gateway=192.168.1.1
ether2=192.168.2.2 gateway=192.168.2.1
ether3=local gateway=192.168.88.1 dhcp=192.168.88.100-192.168.88.200
wan1 wan2 สมมุติว่ามาจากพวก tot wi-net, Airnet,fiber optic หรือพวก cable ที่มันเซตเป็น PPPoE ที่ Mikrorik ไม่ได้
วิธีการรวมเนต 2 เส้นให้ได้ก่อนนะครับ
ตัวอย่างที่ผมเทส wan1=เนตที่ทำงาน 7 Mbps/512 kbps wan2=@TRUEWIFI 12 Mbps/1Mbps
เซตเป็น PPPoE อยู่

จ่าย IP 192.168.1.2-192.168.1.33 จำนวน 32 IP

RouterBoard ที่เอามาเทสจัดเป็นตัวใหญ่เลย RB1100AHx2

ผลเทสกับบิททอเร้นท์ครับ @TRUEWIFI ไม่นิ่งเท่าไหร่ บางทีก็ได้ความเร็วไม่ตรง ความเร็วสูงสุดที่เห็น 2.3 MB/s

จัดการ forward Port โมเดมของ wan 1 ให้ Port 8291 และ 81 ไปลงที่ IP 192.168.1.2
โดยไปที่ Advance Setup และ NAT บางรุ่นอาจยาก บางรุ่นอาจง่าย ลองกับ ST356 V6 ปวดหัวกันเลย
ต้องมาลงที่ตัวนี้ HATARI เร้าเตอร์แถม 3BB

หน้า forward Port ครับ
.png)
เรียบง่ายดีครับ

วิธีการ Mikrotik Send IP to EMAILเคยเขียนไว้แล้วแต่ครั้งนั้นเซตแบบ PPPoE
หน้า Interface ของ Mikrotik ครับ

ไปที่ Tools>>>Email
Server:173.194.77.108
Port:587
Form:user ของเรา@gmail.com
User:user ของเรา@gmail.com
Password: password ที่ login เข้า Gmail

ไปที่ System>>>Script
กด+ สร้างสคริปท์ชื่อ Send_Email ติ๊กถูกตรง read,write,test
แล้ว copy สคริปท์ด้านล่างลงไปครับ
หากต้องการให้ส่ง WAN2 ด้วย ต้องสร้างสคริปท์ขึั้นมา 2 อัน คือ Send_Email1 และ Send_Email2
ตัว Scheduler ก็ต้องสร้างด้วย และ Allow Firewall Port ที่ ether2 ด้วยครับ (กรณีของผม @TRUEWIFI มันไม่ได้ IP จริงเลยไม่ทำ)
global currentIP;
# 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 newIP [/file get dyndns.checkip.html contents]
:if ($newIP != $currentIP) do={
:put "ip address $currentIP changed to $newIP";
:set currentIP $newIP;
/tool e-mail send to= user gmail ของเรา@gmail.com subject="WiFi4YOU wan1$newIP" body=" wan1= $newIP" tls=yes
}

สร้าง Scheduler ให้ทำงาน
ตั้งไว้ 10 นาที เพื่อตรวจสอบว่า ip ใหม่หรือเก่าถ้าใหม่ก็จะส่ง mail แต่ถ้าได้ ip เดิมก็จะไม่ส่ง
อันนี้ง่ายครับ
/system scheduler
add name=Send_Email interval=00:10:00 on-event="/system script run Send_Email\r\n"
copy วางใน Terminal เลย
.png)
แล้วจะเห็น /system scheduler ที่สร้างขึ้นมาครับ
ติ๊กถูกตรง read,write,test

Allow Firewall Port 81 (www) 8291 (winbox)ในตัว Mikrotik ที่ ether1 หากจะทำ 2 wan ก็เพิ่ม wan อีกด้วยครับ
ทำใน Terminal copy วางเลยครับ
หากไม่ทำตรงนี้ firewall ของ Mikrotik จะบล็อคไม่ให้เข้า WinBox ครับ
/
/ip firewall filter
add action=accept chain=input comment="allow tcp port 81 Webfig" disabled=no \
dst-port=81 in-interface=ether1protocol=tcp
/
/
/ip firewall filter
add action=accept chain=input comment="allow tcp port 8291 WinBox" disabled=no \
dst-port=8291 in-interface=ether1protocol=tcp

ทดสอบ Mikrotik ส่ง IP มาให้แล้ว
.png)
copy IP ที่ได้มาจาก GMAIL

เข้าได้ครับ
.png)
ถ้าไม่ใส่ Port จะเข้าโมเดมเร้าเตอร์ ครับ
.png)
ถ้าใส่ :81 จะเข้าหน้า webfig

ถ้าใส่ :81/userman จะเข้า userman

หรือถ้าไม่ใช้ IP Send Email ก็ใส่เป็น ddns ที่หน้า ddns ของที่เร้าเตอร์เลยก็ได้
เวลาเรียกเข้าก็ใส่เป็น ddns เลย แบบนี้ก็ง่ายดี สำหรับคนที่มี ddns อยู่แล้ว
คงพอทำได้นะครับ สำหรับวันนี้สวัสดีครับ