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

  • การตั้ง Scheduler ในอุปกรณ์ Mikrotik เพื่อทำการ Block User ตามช่วงเวลา
    เริ่มโดย yod
    Read 49,682 times
0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

 

 
Mikrotik 450G ทำได้ไหมครับผม

ขอบคุณครับ

yod

/system script
add name=block-user-grp1 policy=read,write source="/ip hotspot user disable [find profile=userprof1]\r\
    \n:local i\r\
    \n:foreach i in=[ /ip hotspot user find where disabled=yes ] do={\r\
    \n:local name [/ip hotspot user get \$i name]\r\
    \n[ /ip hotspot active remove [find where user=\$user] ]\r\
    \n#:log info \$name\r\
    \n}"
add name=block-user-grp2 policy=read,write source="/ip hotspot user disable [find profile=userprof2]\r\
    \n:local i\r\
    \n:foreach i in=[ /ip hotspot user find where disabled=yes ] do={\r\
    \n:local name [/ip hotspot user get \$i name]\r\
    \n[ /ip hotspot active remove [find where user=\$user] ]\r\
    \n#:log info \$name\r\
    \n}"


ตรงนี้เป็นแค่ส่วนของ Code Block หรือป่าวครับ
ในส่วนของ Unblock ต้องทำอีกอัน พอดีมะกี้ผมลองแล้วได้มาเป็นประมาณนี้

/system script
add name=unblock-user-grp1 policy=read,write source="/ip hotspot user enable [find profile=userprof1]\r\
    \n:local i\r\
    \n:foreach i in=[ /ip hotspot user find where disabled=yes ] do={\r\
    \n:local name [/ip hotspot user get \$i name]\r\
    \n[ /ip hotspot active remove [find where user=\$user] ]\r\
    \n#:log info \$name\r\
    \n}"

code ลบ  user ใน profile
-------------------------------------------------------------------------------------------
/ip hotspot user disable [find profile=userprofile1]
:foreach user in=[/ip hotspot user find profile=userprofile1] do={
:foreach activeuser in=[/ip hotspot active find name=$user] do={
/ip hotspot active remove $activeuser
}
/ip hotspot user disable $user
}

------------------------------------------------------------------------------------------------------------------------------------------------







คือผมกำลังทำระบบ hotspot โดยใช้ mikrotik hAP lite  ทำเป็นขายบัตรแบบรายวัน แบบ username และ password มีกำหนดระยะเวลาใช้งาน 24 ชั่วโมง  และต้องการให้ user ที่ใช้งานเมื่อครบเวลา 24 ชั่วโมงแล้วให้ระบบเตะออก  และลบ user  นั้นออกไป
เพราะที่เป็นอยู่ตอนนี้คือ username  สามารถใช้งานซ้ำได้