OPNsense Forum

English Forums => General Discussion => Topic started by: PilaScat on May 21, 2025, 04:56:59 PM

Title: Traffic Shaping for Plex servers
Post by: PilaScat on May 21, 2025, 04:56:59 PM
Hi, I'm trying to reserve upload traffic for my Plex Servers, when other services are uploading and using my entire bandwidth (1 Gbit) Plex starts to lag, I would like to avoid that, I would like to add a priority rather than reserving bandwidth, also because often it's not in use and I would like to use the bandwidth that it's not using, I have tried many combinations but it's not very clear how to do it
My actual config (don't know if it is correct) is attached
I would like to reserve 300 Mbit to Plex, and the other for ALL other traffic (700 Mbit)
I have tow Plex servers, on 192.168.1.20 at ports 32400 and 32450
Thank you in advance
Title: Re: Traffic Shaping for Plex servers
Post by: meyergru on May 21, 2025, 06:32:12 PM
See: https://docs.opnsense.org/manual/how-tos/shaper_prioritize_using_queues.html

The essential thing here is that you need three things for this to work:

1. A pipe with the total bandwidth for the traffic direction in question, in your case 1000 MBits for upstream.
2. Two queues with different weights on that pipe, the sum of the weights should be 100, so in your case, low-prio-queue = 30 and high-prio-queue = 70.
3. Two rules, one for your high-prio clients, using the high-prio-queue, with a list of src IPs in your network, with a direction "out" and a second one for the low-prio-queue with src = any and direction out. These rules must come with sequence numbers such that the first, more specific rule has a lower number in order to fire before the second rule, which applies to "everything" else.

Your setup seems mostly consistent with that, but I do not see all of the specific settings, e.g. the ports should be "any" for upstream use.

Also, take a look at this thread: https://forum.opnsense.org/index.php?topic=46990.0

It seems at this time, changing the traffic shaper sometimes shows a glitch, where a reboot is needed to actually make it work.
Title: Re: Traffic Shaping for Plex servers
Post by: PilaScat on May 21, 2025, 08:08:23 PM
Attached the first and the second one, tell me if I am wrong
Title: Re: Traffic Shaping for Plex servers
Post by: meyergru on May 21, 2025, 08:15:05 PM
As I wrote, I would not use the Src-port limitation. You do not know what source port will be used beforehand, even if there was just one server running on port 32400. That port does not say anything about which port the outbound connection will originate from. Thus, the IP alone should be the only selector for the first rule.

Other than that, the rules look correct. There still is the other problem I mentioned.
Title: Re: Traffic Shaping for Plex servers
Post by: PilaScat on May 21, 2025, 08:49:31 PM
The problem is that I run many services and VMs on the server, most of the traffic comes from there, I need to prioritise only Plex
Title: Re: Traffic Shaping for Plex servers
Post by: meyergru on May 21, 2025, 10:44:00 PM
If those are really VMs or LXCs, they have different IPs, so I must assume you really talk about containers on the same Docker host.

I think that Plex handles the connections between a client and a server via an outbound HTTPS control channel and the way it connects a client can differ very much. If you open a port and the other partner can connect to that, then fine. But that is not always the case, think CG-NAT. In such cases, there must be some other connection that actually handles the traffic - maybe over the control channel itself. This connection can use any src port.

So, you will have to make sure that your high priority rule is not too narrow to actually catch the traffic you want to promote.

Lastly, the "ip" protocol does not even have ports - only tcp and udp have that.
Title: Re: Traffic Shaping for Plex servers
Post by: PilaScat on May 21, 2025, 11:47:07 PM
Yes is docker, for now I have port 32400 and 32450 opened via port forwarding, so they should be only that
Title: Re: Traffic Shaping for Plex servers
Post by: meyergru on May 22, 2025, 12:29:01 AM
If you are sure. I am not, as depicted. Fact of the matter is that it does not work for you, so I figure it is your obligation to find out, why. So: Did you verify or do you just assume this?

Also: did you try changing the protocol if you use the port setting?
And: have you rebooted after making changes before trying?