OPNsense Router
Three conveyor belts carry blue packet cubes into a gray five-port router, with one cube dropped into a bin, depicting queue management and traffic shaping.
Configuration

OPNsense Traffic Shaping and QoS Explained: FQ-CoDel

Configure OPNsense traffic shaping with pipes, queues and rules. Set up FQ-CoDel for bufferbloat, cap guest bandwidth and share a pipe by weight.

By OPNsense Router Editorial · ·Updated · 8 min read

Yes, OPNsense provides QoS under Firewall ‣ Shaper. Pipes set bandwidth caps, queues can share a pipe by weight, and rules send matching traffic to a pipe or queue. For WAN bufferbloat, start with one FQ-CoDel pipe per direction, each set to 85% of the ISP’s advertised rate. Traffic shaping overview · FQ-CoDel setup

What does OPNsense traffic shaping actually do?

Setting the pipe rates below the bottleneck gives OPNsense a queue it can manage. That helps address bufferbloat, the excess latency caused by a persistent queue. OPNsense FQ-CoDel how-to · RFC 8289

The shaper uses IPFW and dummynet. Shaping rules are handled separately from firewall rules unless a firewall rule assigns a pipe or queue directly. For dummynet, OPNsense recommends a minimum kern.hz of 1000 and places that tunable under System ‣ Settings ‣ Tunables. OPNsense traffic shaping · FreeBSD dummynet manual

How pipes, queues and rules fit together

ObjectWhat it doesFields that matter
PipeSets the bandwidth for matching trafficBandwidth, scheduler type, mask, CoDel settings
QueueAssociates traffic with a pipe and can give it a weighted sharePipe, weight (1 to 100, default 100), mask
RuleSends matching traffic to a pipe or queueSequence, interface, interface 2, protocol, source, destination, ports, direction, DSCP, target

OPNsense traffic shaping · Traffic shaper model

Direction. For WAN shaping, use in for download and out for upload. The default direction, Both, matches incoming and outgoing traffic. FQ-CoDel rule example

Masks. A mask on a pipe creates a dynamic pipe per matching address, each with the configured rate. The per-user example gives each host on 192.168.1.0/24 a 1 Mbit/s cap. A mask on a queue lets hosts share the bandwidth of one pipe. Both examples use a destination mask for download and a source mask for upload. Limit bandwidth per user · Share bandwidth evenly

Sequence. Give a specific rule a lower sequence than any catch-all rule that would match the same traffic. Leave gaps for additional rules. Control plane shaping

Which scheduler should you pick?

Use FlowQueue-CoDel to reduce WAN latency under load. Use Weighted Fair Queueing (WFQ) or QFQ when you need queue weights to determine shares. Traffic shaper model · FQ-CoDel setup · Control plane shaping

SchedulerHow it fits
Weighted Fair Queueing (default scheduler)Supports weighted shares and control plane classes
FlowQueue-CoDelManages WAN queue delay and shares capacity across flows
FlowQueue-PIEUses active queue management. The control plane guide flags its congestion feedback
QFQSupports weighted shares and control plane classes
Deficit Round RobinThe control plane guide flags latency
FIFOServes packets in arrival order

How FQ-CoDel reduces bufferbloat

FQ-CoDel hashes flows into queues using the protocol, source and destination IP addresses, and source and destination ports. Deficit round robin shares service among queues, with prompt service for sparse traffic such as DNS. In each queue, CoDel tracks how long packets have waited and signals persistent congestion by dropping packets or marking ECN-capable traffic. RFC 8290 · RFC 8289

ParameterOPNsense defaultTuning guidance
Target5 msFor low bandwidth, try the average round-trip time to the first hop after OPNsense, rounded up
Interval100 msStart with the default
Quantum1514 bytesMatch the WAN MTU. The guide leaves this at the default for Ethernet
Limit10240 packetsThe tuning guide suggests about 1000 for connections below 10 Gbit/s
Flows1024A change requires a reboot. Setting this too high can hang the device
ECNOffThe setup enables it. The tuning guide advises turning it off on uplinks below 4 Mbit/s

OPNsense FQ-CoDel parameters and tuning

How to set up FQ-CoDel on OPNsense

On an example 500/40 Mbit/s plan, 85% gives starting rates of 425 Mbit/s down and 34 Mbit/s up. This example uses higher rule sequences to leave room for control plane rules. FQ-CoDel setup · Control plane rule order

  1. Before applying the shaper, run several speed tests and record download rate, upload rate and latency. Use the same test for subsequent measurements.

  2. Open Firewall ‣ Shaper ‣ Pipes and select advanced mode. Create enabled Download and Upload pipes at 425 and 34 Mbit/s, respectively.

  3. On each pipe, select FlowQueue-CoDel and enable (FQ-)CoDel ECN. Leave the mask and Enable CoDel unset, and start with the default limit, flows, target and interval. Use the default quantum for Ethernet.

  4. Under Queues, create Download-Queue on Download and Upload-Queue on Upload. Enable both, set weight to 100 and leave the masks and queue CoDel settings empty.

  5. Under Rules, create these enabled rules. For both, use interface WAN, protocol ip, and any for addresses and ports.

    TrafficSequenceDirectionTarget
    Download100inDownload-Queue
    Upload110outUpload-Queue
  6. Select Apply. Run the same speed test, then raise the download rate in small steps and retest each time. When latency rises, back off to the last rate that kept it low. Repeat for upload.

Optional target tuning. From the OPNsense shell, identify the first hop after the firewall with traceroute 1.1.1.1. Run ping -s 1472 -c 1000 -D <hop-ip> with that hop’s address, then round the average round-trip time up for the Target setting. Target and interval tuning

When do weighted queues make sense?

Use weighted queues when competing applications need proportional shares of one pipe. The control plane how-to identifies WFQ and QFQ as schedulers that honor queue weights. A lower-weight queue retains its share even while a higher-weight queue stays backlogged. Control plane shaping · Traffic shaping overview

The weighted queues example puts Queue-SMTP (weight 9) and Queue-HTTP (weight 1) on a 10 Mbit/s download pipe. The example’s WAN rules match these source ports. When both queues are backlogged, SMTP gets 9 Mbit/s and HTTP and HTTPS share 1 Mbit/s. Prioritize applications using queues

SequenceSource portTarget
1125 (SMTP)Queue-SMTP
2180 (HTTP)Queue-HTTP
31443 (HTTPS)Queue-HTTP

Rules can also match DSCP. For example, send packets marked Expedited Forwarding (EF) to a weighted queue to give them a share under contention. Traffic shaper model · Traffic shaping overview

How do you cap bandwidth for GuestNet?

The standalone GuestNet example caps the entire guest network at 2 Mbit/s down and 1 Mbit/s up on a symmetric 10 Mbit/s connection. It uses two pipes and two WAN rules, with each rule targeting a pipe directly. The caps apply only to GuestNet. OPNsense GuestNet how-to

On Pipes, create the enabled pipes with empty masks. On Rules, create the matching rules in advanced mode. Set Interface to WAN, Interface 2 to GuestNet and protocol to ip on both rules. Leave addresses and ports at any. GuestNet pipe and rule settings

TrafficPipe and rule targetPipe rateRule sequenceRule direction
DownloadPipeDown-2Mbps2 Mbit/s11in
UploadPipeUp-1Mbps1 Mbit/s21out

Select Apply to activate the rules.

Do you need a control plane class for IPv6?

Consider a dedicated class if you run IPv6 or dynamic routing. The OPNsense example matches ipv6-icmp and uses WFQ or QFQ to reserve capacity. The guide flags FQ-CoDel and FQ-PIE for their congestion feedback. FQ-CoDel guidance · Control plane shaping

  1. Open Firewall ‣ Shaper ‣ Pipes in advanced mode. Create an enabled pipe per direction at 1% of the tuned bandwidth, with a minimum of 1 Mbit/s. Select WFQ or QFQ.
  2. Under Queues, create one enabled queue per pipe at weight 100. Reserve these pipes and queues for control plane traffic.
  3. Under Rules, create one enabled rule per direction on WAN. Use protocol ipv6-icmp, leave addresses and ports at any, and target the corresponding queue. Set download to in and upload to out.
  4. Give both rules lower sequences than the catch-alls. Subtract the reserved bandwidth from the corresponding FQ-CoDel pipes and select Apply.

For the example above, if the tuned rates are 425/34 Mbit/s, round 1% of 425 up to 5 Mbit/s and use the 1 Mbit/s minimum for upload. Put the control plane rules at sequences 10 and 20 and trim the main pipes to 420 and 33 Mbit/s. For additional protocols, add matching rules and queues to the control plane pipes. Control plane example

The guide lists OSPF and BGP as control plane traffic. For tunnel configuration, see OPNsense WireGuard site-to-site.

How to check that shaping works

Open Firewall ‣ Shaper ‣ Status to see traffic passed since the service last restarted. Select Show rules for per-rule data or Show active flows for flow details, then refresh. From the shell, use dnctl pipe show and dnctl queue show to list pipes and queues. OPNsense shaper status · FreeBSD ipfw manual

If latency stays high under load, check the status counters while you retest. Confirm that WAN download uses in, WAN upload uses out, and the intended rule comes before any matching catch-all. Retune one pipe at a time using the same speed test. FQ-CoDel tuning · Control plane rule order

What does shaping cost?

OPNsense describes its shaper as having a low CPU footprint. Its FQ-CoDel guide notes that a smaller quantum can increase CPU work. Traffic shaping overview · FQ-CoDel quantum tuning

For hardware sizing and VPN trade-offs, see OPNsense hardware requirements and WireGuard vs OpenVPN vs IPsec on OPNsense.

Evidence and limits. The configuration is based on OPNsense documentation and the traffic shaper model, with OPNsense CE 26.7 release notes for version context. The steps were checked against the cited documentation and were not run on a firewall.

Sources

  1. Traffic Shaping - OPNsense documentation
  2. Fighting Bufferbloat with FQ_CoDel - OPNsense documentation
  3. Control Plane Shaping - OPNsense documentation
  4. Prioritize using Queues - OPNsense documentation
  5. Share bandwidth evenly - OPNsense documentation
  6. Limit bandwidth per user - OPNsense documentation
  7. Multi interface shaping for a GuestNet - OPNsense documentation
  8. TrafficShaper.xml model definition - opnsense/core
  9. RFC 8290: The Flow Queue CoDel Packet Scheduler and Active Queue Management Algorithm
  10. RFC 8289: Controlled Delay Active Queue Management
  11. dummynet(4) - FreeBSD Manual Pages
  12. ipfw(8) and dnctl - FreeBSD Manual Pages
  13. OPNsense CE 26.7 release notes

Related