Bandwidth Rules
Bandwidth Rules let you change every subscriber’s speed on a schedule, without touching their service plan. A typical use is a NIGHT rule that doubles speeds from 23:00 to 07:00, or a MAINTENANCE rule that halves speeds during a specific window for testing.
Rules are stored in the bandwidth_rules table and applied by the BandwidthRuleService background goroutine. Every 30 seconds the service checks active windows and pushes Mikrotik-Rate-Limit updates via CoA (with MikroTik API fallback).
How to get here
Section titled “How to get here”Sidebar → Bandwidth Rules. Direct URL: /bandwidth.
Requires bandwidth.view. Most resellers see this read-only; admin or a reseller with bandwidth.create/edit/delete can modify.
Layout
Section titled “Layout”| Section | What it shows |
|---|---|
| Rules table | Name, Trigger Type, Time window, Days, Multipliers, Services, Priority, Enabled, Auto-Apply, Actions |
| Add Rule button | Create a new rule |
| Per-service overrides modal | Inside each rule edit — override the global multipliers for specific services |
Rule fields
Section titled “Rule fields”| Field | Notes |
|---|---|
| Name* | E.g. NIGHT, WEEKEND, MAINTENANCE. Surfaced in subscriber logs when applied. |
| Trigger Type | time (default), quota, or fup. Only time is fully implemented today; quota and fup are reserved for future use. |
| Start Time | HH:MM in system timezone. |
| End Time | HH:MM. Windows that cross midnight are supported (e.g. 23:00 → 07:00). |
| Days of Week | JSON array, e.g. [1,2,3,4,5] for weekdays (1 = Monday, 7 = Sunday). Empty array = every day. |
| Upload Multiplier | Integer percent. 100 = unchanged, 200 = double speed, 50 = half. |
| Download Multiplier | Same. |
| Service IDs | JSON array of service IDs the rule applies to. Empty = applies to all services. |
| Priority | Lower number = higher priority (1 wins over 10). When multiple rules overlap, the lowest-priority-number rule is applied. |
| Enabled | Master on/off without deleting. |
| Auto-Apply | If on, applies automatically every 30 s while the window is active. If off, the rule is a template that has to be applied manually via Apply Now. |
Per-service multiplier overrides
Section titled “Per-service multiplier overrides”A rule’s global multipliers can be overridden per service via the bandwidth_rule_service_multipliers table. Click Edit on a rule → Per-service overrides to set specific multipliers for individual services.
Example: a NIGHT rule with global 200% multiplier, but you don’t want the 100 Mbps tier to double (your backbone can’t sustain it). Add a per-service override for the 100 Mbps service with multiplier 100%, leaving everything else at 200%.
When applying, the service handler looks up the per-service multiplier first, falling back to the rule’s global multiplier if no override exists.
How it stacks — the speed priority order
Section titled “How it stacks — the speed priority order”Final speed for any subscriber is computed in this order (each step is multiplied):
- Subscriber bandwidth rule (per-user custom speed override from
subscriber_bandwidth_rules) — if active, replaces the service’s base speed. - FUP speed (if the user’s
fup_level > 0) — replaces base speed with the FUP-tier speed. - Service base speed — if neither 1 nor 2.
That base speed is then multiplied by the active global Bandwidth Rule if any. Formula:
final_speed = base_speed × (bandwidth_rule_multiplier ÷ 100)Important: if both a global Bandwidth Rule AND the service’s own Free Hours / Time-Based Speed are configured for the same window, only the global Bandwidth Rule is applied — to prevent double-boosting.
How rules are applied
Section titled “How rules are applied”On each 30 s cycle, BandwidthRuleService:
- Loads all
enabled = true AND auto_apply = truerules. - For each, checks
now() in window. If not, looks for queues previously tagged with this rule and restores the original speed. - If active, iterates online subscribers grouped by NAS. For each subscriber:
- Looks up the subscriber’s effective base speed (per the priority order above).
- Multiplies by the rule’s multiplier (or per-service override if defined).
- Calls
UpdateUserRateLimitWithIPon the MikroTik (kb format, no conversion). - Falls back to CoA
UpdateRateLimitif API fails.
- Logs
Applied X to user@domainper success.
A read-only audit map (appliedToQueues) tracks what’s been changed so the restore phase only restores queues this rule actually modified. This prevents one rule from undoing another rule’s changes.
Speed unit reminder
Section titled “Speed unit reminder”Speeds throughout ProxPanel are in kb (kilobits). The bandwidth rule service was previously buggy here — pre-v1.0.149 it multiplied speeds by 1000, treating download_speed as Mbps. A 1200k service with a 200% NIGHT rule was getting 1.2 Gbps on MikroTik instead of 2.4 Mbps. Fixed across bandwidth_rule_service.go and cdn_bandwidth_rule_service.go.
Apply Now (manual trigger)
Section titled “Apply Now (manual trigger)”For rules with auto_apply = false, the Apply Now button on the row immediately runs one pass of the rule against all matching subscribers. Use this for ad-hoc maintenance windows where you don’t want the rule firing on a schedule.
Auto-Apply vs. manual
Section titled “Auto-Apply vs. manual”| Mode | When the rule fires | Use case |
|---|---|---|
| Auto-apply = on | Every 30 s while window is active | Regular schedules like NIGHT, WEEKEND |
| Auto-apply = off | Only when Apply Now is clicked | One-shot maintenance, A/B tests |
CDN Bandwidth Rules
Section titled “CDN Bandwidth Rules”CDN-specific bandwidth rules live in a separate page (CDN → Bandwidth Rules) and operate on PCQ queues instead of the main per-user simple queue. The logic mirrors what’s described here but only touches CDN-traffic queues. See CDN Management.
Common workflows
Section titled “Common workflows”Create a “Friday Night Free” rule (Fri 18:00 → Sat 06:00)
Section titled “Create a “Friday Night Free” rule (Fri 18:00 → Sat 06:00)”- Add Rule → name
FRIDAY-NIGHT. - Start Time
18:00, End Time06:00. - Days of Week — select Friday only. (The window naturally rolls into Saturday morning.)
- Upload + Download Multiplier —
300(triple speed). - Priority
10, Enabled, Auto-Apply ON. - Save. The next 30-second cycle picks it up if you’re inside the window.
Halve bandwidth on a misbehaving NAS for one hour
Section titled “Halve bandwidth on a misbehaving NAS for one hour”- Add Rule → name
MAINTENANCE-NAS-3. - Service IDs — leave blank to hit everyone.
- Multipliers
50/50. - Auto-Apply OFF, Enabled ON.
- Save.
- Click Apply Now. All subscribers on the NAS get halved speeds via CoA.
- After your maintenance, edit the rule to clear/disable and click Apply Now again to restore.
Boost only the 10 Mbps tier subscribers at night
Section titled “Boost only the 10 Mbps tier subscribers at night”- Add Rule NIGHT-10M, Window
00:00 → 06:00, Multiplier200%. - Set Service IDs to just the 10 Mbps service.
- Save. Only those subscribers see doubled speed at night; 100 Mbps subscribers stay at their normal rate.
Permissions
Section titled “Permissions”| Permission | Effect |
|---|---|
bandwidth.view | Page loads. |
bandwidth.create | Add Rule button. |
bandwidth.edit | Edit + Apply Now buttons. |
bandwidth.delete | Delete button. |
subscribers.bandwidth_rules | Per-subscriber rules tab on the Subscriber Detail page. |
Related pages
Section titled “Related pages”- Services & Plans — base speeds that bandwidth rules multiply.
- Subscriber Detail Page — Bandwidth Rules tab for per-subscriber overrides.
- CDN Management — separate bandwidth rule system that targets PCQ queues.
- FUP Counters — see who’s already throttled before adding more rules.
- NAS / Routers — bandwidth rules push to MikroTik via the NAS’s API + CoA.