152. Mikrotik Hotspot Share User Share Bandwidth with Multi Devices/Users




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
:global DDR "20000"
:global DUR "16000"
:local UName $user

# 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]

:if ($DeviceCount =0) do={

# Set Queue Per Device
:local DQPerDevice ($DDR / $DeviceCount)
:local UQPerDevice ($DUR / $DeviceCount)

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

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

}\

else={

# Set Queue Per Device
:local DQPerDevice ($DDR / $DeviceCount)
:local UQPerDevice ($DUR / $DeviceCount)

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

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

}
#PhallaCCMT.blogspot.com


Logout Script:
:local UName $user;

# 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 ??"

}\

else={

# Set Queue Per Device
:local DQPerDevice ($DDR / $DeviceCount)
:local UQPerDevice ($DUR / $DeviceCount)

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

}

#PhallaCCMT.blogspot.com


Previous
Next Post »

3 comments

Write comments
raul garcia
AUTHOR
December 28, 2018 at 9:24 PM delete

saludos, no me funciona estoy usando autenticacion por mac y mi rb esta con la ultima version 6.43.8, cual podria ser el problema

Reply
avatar
Abyan
AUTHOR
December 18, 2019 at 12:02 PM delete

How to improve maximum user device limit source?

Reply
avatar
Unknown
AUTHOR
February 24, 2020 at 6:19 PM delete

how to add the expiration of the user? E.g It will only be valid for days?

Reply
avatar