Traffic Shaping in OPNsense

In this guide I will show you how to set up traffic shaping with fq_codel. I have done this on my own OPNsense firewall with a 500 Mbit/s download and 35Mbit upload speed and improved my BufferBloat rating from a B to an A (test here). If anyone is interested in the source of this information, I found a simple guide on the OPNsense forum here.

Pipes

First thing we need to do is create two pipes. We can do this by going to the OPNsense dashboard and then finding your way to Firewall --> Shaper --> Pipes.

Here we will create two pipes, one for downloading and another for uploading traffic. To create a pipe we first select the little plus icon on the right side of the screen.

Download Pipe

Once click the plus icon a small window will pop up. We need to make sure that "advanced mode" is enabled (top left corner). Firstly, lets enable the pipe pipe by checking the "Enabled" box. Now you will be able to add your bandwidth accordingly. My home download speed as I explained earlier is 500 Mbit/s so I put that in here, you will have to put your own in. Next you will need to enable (FQ-)CoDel ECN, set Scheduler type to "FlowQueue-Co-Del" and set Queue to 2. For the "FQ-CoDel quantum" value, the optimal rule seems to be 300 per 100 Mbps. So for my speed in terms of Gigabits I did 300 * 5 = 1,500 . For the description simply add "Download". Now click save and let's move onto the upload pipe.

TIP

After making any changes during this guide, it is advised that you click apply after making any changes to apply them to your firewall.

Upload Pipe

For the upload pipe we only need to make a few changes. Add your bandwidth as per the download pipe (but use your upload speed), enable (FQ-)CoDel ECN, set Scheduler type to FlowQueue-Co-Del and fill in the description as "Upload". Click save and then apply.

Queues

Now switch to the Queues tab and we will add two queues, one for download and one for upload.

Download Queue

As before we will create the first queue by clicking the plus icon on the right side of the window. Enable (FQ-)CoDel ECN, select the "Download" pipe, set the weight to 100 and select "destination" as the mask. We now need to add a description for this queue as "Download Queue". Click save and then apply.

Upload Queue

For the upload queue we pretty much do the same but choose "Upload" for the pipe and "source" for the mask. We will now add "Upload Queue" to the description. Click save and then apply.

Rules

Let's now switch to the Rules tab and set up two rules.

Download Rule

As before, select the little plus icon to create a new rule. Here we need to make sure the "advanced mode" is enabled in order to show all of the settings we need. Make sure that this rule is enabled firstly. Most of these settings we can leave as default but just check the settings against the screenshot below. We will need to change the Direction to "in" and then the Target to be the "Download Queue" we created before. Set the Description here to be "Download Rule". Click save and then apply.

Upload Rule

The upload rule is pretty much exactly the same except the Direction needs to be "out" and the Target needs to be our "Upload Queue". Set the Description here to be "Upload Rule". Click save and then apply.

Conclusion

Our traffic shaping should now be working and your buffer bloat rating should have improved.

Support Us

Thank you for being part of our community!

Last updated