125. Mikrotik Hotspot: Share User, Share Bandwidth for Multi Devices

You can contact me: plus.google.com/+PhallaCCMT; youtube.com/phallaccmt; facebook.com/Phalla.CCMT; twitter.com/PhallaCCMT and Phalla.CCMT@gmail.com

Login Script:

# Set Default Rate Limit k/s #Set User # Set User Profile
:global DRateLimit "9000"
:global UName "asd"
:global ProName "MultiShare_Pro"

# Remove Default Queue
/queue simple remove [/queue simple find name~"$UName"]

# Count Login Device
:local DeviceCount [/ip hotspot active print count-only where user=$UName]

# Set Queue Per Device
:local QPerDevice ($DRateLimit / $DeviceCount)

# Add Queue to New Login Device 
/queue simple add name=$address target=$address max-limit=($QPerDevice."k/".$QPerDevice."k") comment=$user place-before=0;

# Reset Queue to Logined Device
:foreach QReset in=[/queue simple find comment =$UName] do={/queue simple set $QReset max-limit=($QPerDevice."k/".$QPerDevice."k")} 

#PhallaCCMT.blogspot.com



Logout Scrip:

# Remove Queue From Logout Device
/queue simple remove [/queue simple find name =$address]

# Count Device Login
:local DeviceCount [/ip hotspot active print count-only where user=$UName]

# --------------------if all Device Logout

:if ($DeviceCount =0) do={

:log info "All are Devices Logout :D"

}\

else={

# Set Queue Per Device
:local QPerDevice ($DRateLimit / $DeviceCount)

# Reset Queue to Logined Device
:foreach QReset in=[/queue simple find comment =$UName] do={/queue simple set $QReset max-limit=($QPerDevice."k/".$QPerDevice."k")}

}

#PhallaCCMT.blogspot.com


Previous
Next Post »

3 comments

Write comments
Artha Tjokro
AUTHOR
September 25, 2017 at 10:43 AM delete

dear,
can I , combine this scrip with limit youtube or download?

Reply
avatar
Asim Ameen
AUTHOR
January 16, 2018 at 4:43 PM delete

Hi .
Will You Send Me 4 Wan Load Balancing script for Mikrotik Hotspot Server...

Thank you ...

Reply
avatar
August 30, 2018 at 9:30 PM delete

bandwidth limit calculation only work if user logout from "logout" button,
bandwidth not recalculated if they had autologout (example : loss connection)
can you fix this bug?

Reply
avatar