Of course! You've perfectly described the goal of Class-Based Weighted Fair Queuing (CBWFQ). The idea is:
- Guarantee a minimum for everyone so critical services always work.
- Allow bursting up to the full available bandwidth if no one else needs it.
- Share fairly when multiple offices are competing for bandwidth.
On a FortiGate, this is achieved using a combination of Shared Shapers and Per-Policy Shapers. Let's build this step-by-step.
The Concept: The Bucket and the Pipes
Imagine your 1 Gbps internet is a large water bucket (the Parent Shaper) that can provide 950,000 Liters/second (950 Mbps).
Each of your 40 VLANs has a small pipe (the Child Shaper) connected to that bucket.
- Each pipe is guaranteed to get 20,000 L/s (20 Mbps).
- If only one pipe is being used, it can draw water as fast as the main bucket can provide it (up to 950,000 L/s).
- If all 40 pipes are demanding water, they each get their guaranteed 20,000 L/s first. Any remaining capacity in the main bucket is then shared fairly among them.
📝 Step-by-Step Configuration Guide
We will configure this in three main stages:
- Create the Parent Shaper (The total internet bandwidth bucket).
- Create the Child Shapers (The guaranteed bandwidth for each VLAN).
- Apply them to your Firewall Policies.
Step 1: Create the "Parent" Shared Shaper
This shaper defines the absolute maximum bandwidth your FortiGate will send to the internet. It's best practice to set this to about 95% of your total ISP speed to account for overhead.
- Your Speed: 1 Gbps (1,000 Mbps)
- Recommended Shaper Speed: ~950 Mbps (or 950,000 Kbps)
-
Navigate to Policy & Objects > Objects > Traffic Shapers.
-
Click Create New.
-
Configure the following:
- Type: Select Shared.
- Name:
Parent_Total_Internet_BW (or something descriptive).
- Traffic Priority: Medium (default is fine).
- Maximum Bandwidth: Enter
950000 (in Kbps).
- Guaranteed Bandwidth: Enter
950000 (in Kbps). For the parent, Max and Guaranteed are the same.
- Enable Per-Policy Traffic Shaping: Do NOT check this box here. This shaper is just the container.
-
Click OK.
Step 2: Create the "Child" Per-Policy Shapers
Now we create a template shaper for each VLAN. This defines their guaranteed bandwidth.
- Total VLANs: 40
- Total Guaranteed Bandwidth Available: Let's use 800 Mbps as our guaranteed pool (800,000 Kbps), leaving 150 Mbps for bursting.
- Guaranteed Bandwidth per VLAN: 800,000 Kbps / 40 VLANs = 20,000 Kbps (20 Mbps).
We will create one shaper for each VLAN (e.g., VLAN10_Guarantee, VLAN20_Guarantee, etc.).
-
Go back to Policy & Objects > Objects > Traffic Shapers.
-
Click Create New.
-
Configure the following for your first VLAN:
- Type: Select Per-Policy.
- Name:
Child_VLAN10_Guarantee (Use the VLAN ID in the name).
- Maximum Bandwidth: Set this to
0. A value of 0 means unlimited, so it will be capped only by the Parent shaper. This is the key to allowing bursting!
- Guaranteed Bandwidth: Enter
20000 (for 20 Mbps in Kbps).
- Traffic Priority: Medium (default is fine).
-
Click OK.
-
Repeat this process for all 40 of your VLANs, changing the name accordingly (e.g., Child_VLAN20_Guarantee, Child_VLAN30_Guarantee, etc.).
Pro Tip: For 40 VLANs, this is tedious. Use the CLI script I provide at the end to do this in seconds.
Step 3: Apply Shapers to Your Firewall Policies
This is where you link everything together. You need to edit each of your 40 outbound firewall policies (the ones that allow each VLAN to access the internet).
-
Navigate to Policy & Objects > Firewall Policy.
-
Find the policy for your first VLAN (e.g., VLAN10_to_WAN). Click to Edit it.
-
Scroll down to the Traffic Shaping section.
-
Configure the fields as follows:
- Traffic Shaper: Select your PARENT shaper (
Parent_Total_Internet_BW).
- Reverse Shaper: Select your PARENT shaper again (
Parent_Total_Internet_BW). This controls download traffic.
- Per-Policy Traffic Shaping: Check this box. A new dropdown will appear.
- In the new dropdown, select the corresponding CHILD shaper for that VLAN (e.g.,
Child_VLAN10_Guarantee).
-
Click OK.
-
Repeat this for all 40 VLAN internet policies, making sure to match the correct Child shaper to the correct VLAN policy.
How It Works in Practice
- Scenario 1: Only VLAN 10 is active. A user on VLAN 10 starts a large download. They are the only one using the internet, so their traffic can burst up to the Parent's limit of 950 Mbps.
- Scenario 2: VLANs 10, 20, and 30 are all downloading heavily.
- FortiGate first ensures each of them gets their guaranteed 20 Mbps. (Total used: 60 Mbps).
- The remaining bandwidth in the Parent bucket (950 - 60 = 890 Mbps) is then distributed fairly between the three active VLANs. They will each get a large portion of that remaining bandwidth.
- If a user on VLAN 40 just checks their email, their traffic goes through without issue because the other three can't consume all the bandwidth.
🧰 CLI Script for Faster Configuration
Manually creating 40 shapers is slow. Use this CLI script.
- SSH into your FortiGate.
- Copy and paste the following commands. You can prepare this in a text editor first.
# === Step 1: Create the PARENT Shared Shaper ===
config firewall shaper traffic-shaper
edit "Parent_Total_Internet_BW"
set type shared
set maximum-bandwidth 950000
set guaranteed-bandwidth 950000
next
end
# === Step 2: Create all 40 CHILD Per-Policy Shapers ===
# (Assuming your VLANs are named VLAN10, VLAN20, etc. Adjust if needed)
config firewall shaper traffic-shaper
edit "Child_VLAN10_Guarantee"
set type per-policy
set guaranteed-bandwidth 20000
set maximum-bandwidth 0
next
edit "Child_VLAN20_Guarantee"
set type per-policy
set guaranteed-bandwidth 20000
set maximum-bandwidth 0
next
edit "Child_VLAN30_Guarantee"
set type per-policy
set guaranteed-bandwidth 20000
set maximum-bandwidth 0
next
# ... continue this pattern for all 40 VLANs ...
edit "Child_VLAN400_Guarantee"
set type per-policy
set guaranteed-bandwidth 20000
set maximum-bandwidth 0
next
end
# === Step 3: Apply to a Firewall Policy (Example for policy ID 15) ===
# You need to find the policy ID for each of your VLANs' internet rules
config firewall policy
edit 15 # <-- CHANGE THIS to the ID of your VLAN 10 policy
set traffic-shaper "Parent_Total_Internet_BW"
set reverse-shaper "Parent_Total_Internet_BW"
set per-policy-shaper "Child_VLAN10_Guarantee"
next
edit 16 # <-- CHANGE THIS to the ID of your VLAN 20 policy
set traffic-shaper "Parent_Total_Internet_BW"
set reverse-shaper "Parent_Total_Internet_BW"
set per-policy-shaper "Child_VLAN20_Guarantee"
next
# ... continue for all policies ...
end
✅ How to Monitor
After implementing this, you can see it in action by going to FortiView > Traffic Shaping. This dashboard will show you all the shapers, how much bandwidth they are currently using, and if any traffic is being dropped because it exceeded the limits.