retnet

auto dhcp to simple queue

Jan 11th, 2026
36
0
Never
5
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. # ===============================
  2. # DHCP Lease Script (Auto Queue)
  3. # ===============================
  4.  
  5. :local queParent "network110"
  6. :local queueName ("Client-" . $leaseActMAC)
  7. :local ipAddr ($leaseActIP . "/32")
  8.  
  9. # ===============================
  10. # Hapus Queue jika lease tidak aktif
  11. # ===============================
  12. :if ($leaseBound != "1") do={
  13. :local old [/queue simple find name=$queueName]
  14. :if ($old != "") do={
  15. /queue simple remove $old
  16. :log info ("Queue removed for " . $leaseActMAC)
  17. }
  18. :return
  19. }
  20.  
  21. # ===============================
  22. # Default limit & burst
  23. # ===============================
  24. :local maxUp "3M"
  25. :local maxDown "3M"
  26. :local burstUp "4M"
  27. :local burstDown "5M"
  28. :local burstTime "30s"
  29. :local burstThresholdUp "2M"
  30. :local burstThresholdDown "3M"
  31.  
  32. # ===============================
  33. # Custom MAC list (set limit & burst)
  34. # ===============================
  35. :if ($leaseActMAC = "F2:CD:FE:C0:81:2C") do={
  36. # rachma
  37. :set maxUp "5M"
  38. :set maxDown "5M"
  39. :set burstUp "10M"
  40. :set burstDown "15M"
  41. :set burstThresholdUp "3M"
  42. :set burstThresholdDown "4M"
  43. }
  44.  
  45. # ===============================
  46. # Buat atau Update Queue
  47. # ===============================
  48. :local exist [/queue simple find name=$queueName]
  49. :if ($exist = "") do={
  50. /queue simple add name=$queueName target=$ipAddr parent=$queParent \
  51. max-limit=($maxUp . "/" . $maxDown) \
  52. burst-limit=($burstUp . "/" . $burstDown) \
  53. burst-threshold=($burstThresholdUp . "/" . $burstThresholdDown) \
  54. burst-time=($burstTime . "/" . $burstTime)
  55. :log info ("Queue created for " . $leaseActMAC . " " . $maxUp . "/" . $maxDown . " with burst " . $burstUp . "/" . $burstDown)
  56. } else={
  57. /queue simple set $exist target=$ipAddr parent=$queParent \
  58. max-limit=($maxUp . "/" . $maxDown) \
  59. burst-limit=($burstUp . "/" . $burstDown) \
  60. burst-threshold=($burstThresholdUp . "/" . $burstThresholdDown) \
  61. burst-time=($burstTime . "/" . $burstTime)
  62. :log info ("Queue updated for " . $leaseActMAC . " " . $maxUp . "/" . $maxDown . " with burst " . $burstUp . "/" . $burstDown)
  63. }
  64.  
  65. # ===============================
  66. # END OF SCRIPT
  67. # ===============================
Tags: mikrotik
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment