Advertisement
slunji

limit shared users per-device

Jul 22nd, 2018
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. 1.copy-paste perintah berikut di new terminal mikrotik :
  2.  
  3. /system scheduler add interval="00:05:00" name="SHARED-USER-LIMIT"
  4.  
  5. 2.copy-paste Script dibawah ini kedalam on-event scheduler "SHARED-USER-LIMIT" :
  6.  
  7. ###########################
  8. # Script By Fajar Rasyadi #
  9. ###########################
  10. # limit shared users per-device
  11. # tanpa harus membuat user-login satu-persatu
  12. ##############################################
  13. # totalquotatamb adalah quota yang ingin kita limit /Mb
  14. :local totalquotamb "200"
  15. :local totalquota ($totalquotamb * 1024 * 1024)
  16. :local datadown
  17. :local dataup
  18. :local totaldata
  19. :local macaddress
  20. ############################################################################
  21. # user="member" ganti sesuaikan dgn yg ada di users anda tanpa tanda kutip #
  22. ############################################################################
  23. :foreach counter in=[/ip hotspot active find user=member] do={
  24. :set datadown [/ip hotspot active get $counter bytes-out]
  25. :set dataup [/ip hotspot active get $counter bytes-in]
  26. :set totaldata ($datadown + $dataup)
  27. :if ($totaldata>$totalquota) do={
  28. :set macaddress [/ip hotspot active get $counter mac-address]
  29. :local inmbdown ($datadown / 1024 / 1024)
  30. :local inmbup ($dataup / 1024 / 1024)
  31. :local inmbtotal ($totaldata / 1024 / 1024)
  32. :log error "ciduk $macaddress"
  33. :log error "pemakaian down $datadown Bytes / $inmbdown MB"
  34. :log error "pemakaian up $dataup Bytes / $inmbup MB"
  35. :log error "pemakaian total $totaldata Bytes / $inmbtotal MB"
  36. ##################################################################
  37. # ganti interval untuk seberapa lama kita ingin memblock device #
  38. ##################################################################
  39. /sys sch add interval=02:25:00 name=$macaddress on-event="/ip hot ip remove [find mac-address=$macaddress]\r\n/sys sch remove [find name=$macaddress]"
  40. /ip hotspot ip add mac-address=$macaddress type=blocked comment="DEVICE-LIMIT"
  41. /ip dhcp-server lease remove [find mac-address=$macaddress]
  42. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement