Popular Forum
- Replies:
- 6
- Words:
- 3296
- Replies:
- 16
- Words:
- 6445
- Replies:
- 0
- Words:
- 1546
- Replies:
- 3
- Words:
- 3596
- Replies:
- 3
- Words:
- 894
Mikrotik Hotspot Bandwith Limit Autodisconnected and AutoKick users
✅ 1. Bandwidth Limit per User (2M/2M)
✅ 2. Auto-Disconnect Inactive Users (10 Minutes)
✅ 3. Auto-Kick Users When Bandwidth Quota is Exceeded
This script uses:
-
Rate-limit on user profile
-
Scheduler for inactivity check
-
Simple Queues + traffic counters to kick users when usage exceeds a quota
-
Example quota: 200MB per user (you can change it)
🚀 FULL MIKROTIK SCRIPT
Paste the whole script into Terminal:
# ---------------------------------------------------- # HOTSPOT: RATE-LIMIT + AUTO-IDLE DISCONNECT + QUOTA # ---------------------------------------------------- # Settings: :local rateLimit "2M/2M" # Speed limit per user :local idleLimit "10m" # Auto-disconnect inactivity time :local quotaLimit 200000000 # 200 MB limit per user (in bytes) # 1. Apply bandwidth limit to ALL Hotspot users /ip hotspot user profile set default rate-limit="$rateLimit" # Optional: If you want a dedicated profile: # /ip hotspot user profile add name="limited" rate-limit="$rateLimit" # ---------------------------------------------------- # 2. Auto-disconnect users who are idle too long # ---------------------------------------------------- /system scheduler remove [find name="auto-disconnect-idle"] /system scheduler add name="auto-disconnect-idle" interval=1m on-event=" :foreach u in=[/ip hotspot active find] do={ :local idle [/ip hotspot active get \$u idle-time]; :if (\$idle > $idleLimit) do={ /ip hotspot active remove \$u; :log warning (\"User auto-disconnected due to inactivity: \" . [/ip hotspot active get \$u user]); } } " comment="Auto-disconnect idle hotspot users" # ---------------------------------------------------- # 3. Auto-kick users when quota is exceeded # ---------------------------------------------------- # Create a scheduler to check usage every minute /system scheduler remove [find name="quota-checker"] /system scheduler add name="quota-checker" interval=1m on-event=" :foreach u in=[/ip hotspot active find] do={ # Get username :local username [/ip hotspot active get \$u user]; # Build queue name (Hotspot queues are created automatically based on username) :local qName \$username; # Check if queue exists :if ([:len [/queue simple find name=\$qName]] > 0) do={ # Get total bytes used (download + upload) :local rx [/queue simple get [find name=\$qName] bytes]; :local total (\$rx->0 + \$rx->1); # Compare with quota :if (\$total > $quotaLimit) do={ # Disconnect the user /ip hotspot active remove \$u; # Reset queue counters /queue simple reset-counters [find name=\$qName]; :log warning (\"User \" . \$username . \" kicked: exceeded quota of $quotaLimit bytes\"); } } } " comment="Auto kick hotspot users exceeding quota" :log info "Hotspot rate-limit, idle-disconnect, and quota control activated!"
📌 How it Works
1. Bandwidth Limit (2M/2M)
Applied via the default Hotspot user profile:
rate-limit="2M/2M"
All users receive:
-
2 Mbps Download
-
2 Mbps Upload
2. Auto-disconnect inactive users
-
The scheduler checks every 1 minute
-
If user idle time > 10 minutes, they are logged out
You can change:
:local idleLimit "10m"
3. Auto-Kick Users When Quota Exceeded
This script:
-
Checks each hotspot user’s simple queue traffic counters
-
Adds up upload + download bytes
-
If total bytes > quota → user is disconnected
-
Queue counters reset, so next session starts fresh
Change the quota here:
:local quotaLimit 200000000
Examples:
| Quota | Bytes |
|---|---|
| 100 MB | - 100000000 |
| 200 MB | - 200000000 |
| 1 GB - | 1000000000 |
| 5 GB - | 5000000000 |
Subscribe to:
Post Comments (Atom)
--Forum Rules --BBcodes
image quote pre code