Quantcast
Channel: Recent Discussions — Plex Forums
Viewing all articles
Browse latest Browse all 151235

HOWTO limit plex media server bandwidth on linux

$
0
0
PMS traffic shaping on linux
I just started using Plex recently. My home router (an Asus RTN-56u, so please don't tell me to get a WRT54GL with DDWRT) doesn't handle QoS properly, and I'm allowing people access to my PMS that may not comply with my request to limit streaming speeds, so I wanted to limit PMS's outgoing speed at the linux level. There are several ways to do this; the easiest is to start PMS with a program called "trickle", but from what I could tell, trickle sounds awesome but simply does not work. My way is much more complicated, but with a cheatsheet here, it should be fairly easy to follow.

I hope this helps someone; traffic shaping on Linux is surprisingly badly documented. I had to go back to manpages and one guy's FAQ on a blog dated 2010 to get this working.

Drop this in /etc/rc.local. It will limit the server to a maximum of 2500 kilobits outgoing on port 32400.

#######
### Setup Traffic Control to limit outgoing bandwidth
### Sourced from
### http://www.cyberciti.biz/faq/linux-traffic-shaping-using-tc-to-control-http-traffic/
#######

### Sleep for a second
sleep 1

### Delete all TC rules for eth0 
/sbin/tc qdisc del dev eth0 root

### Activate queueing discipline
/sbin/tc qdisc add dev eth0 root handle 1:0 htb

### Define class allowed 2500kbit burst to 2500kbit (kbps=kiloBYTES)
/sbin/tc class add dev eth0 parent 1:0 classid 1:10 htb rate 2500kbit ceil 2500kbit prio 0

### Create iptables mangle rule for outgoing port 32400 (Plex Media Server)
/sbin/iptables -A OUTPUT -t mangle -p tcp --sport 32400 ! --dst 192.168.5.0/24 -j MARK --set-mark 10

### Assign the rule to the proper qdisc
/sbin/tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 10 fw flowid 1:10

### Notes
## show TC rules
# /sbin/tc -s -d class show dev eth0
## Show iptables mangle rules
# /sbin/iptables -t mangle -n -v -L
## Show actual bandwidth being used on 32400
# watch -n 1 /sbin/tc -s -d class show dev eth0

Viewing all articles
Browse latest Browse all 151235

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>