2

I'm trying to setup QoS in my VPS so that I can have any new outbound connection to a unique IP gets limited x speed.

For instance:

  • have 5 public IP's requesting data from my VPS.
  • When the VPS sends data back to each of those IP's, each IP gets 10mbps dedicated outbound bandwidth speed.
  • Never drop packets, rather queue them if client surpasses 10mbps.

I don't want to limit the whole eth0 port to 10mbps outbound speed, I want each individual public IP to get 10mbps.

I have frequently different public IP's contacting my VPS so I would rather not have to write rules that are static which force me to write individually each bandwidth rule per IP.

Is this possible with TC qdiscs?

I've looked over what appears to be the typical setup of HTB qdics which allow me to have filters etc. But could not seem to see an example or literature that describes what I want.

I'm using ubuntu server 14.04.

UPDATE

I did the following once I understood the way TC qdiscs work a bit better.

commands I used for a basic setup which appears to work quite smoothly as packets aren't dropping but rather going into the token bucket(note: this is not highly optimized but appears to run stock pretty well):

tc qdisc add dev eth0 root handle 1: htb default 11
tc class add dev eth0 parent 1: classid 1:1 htb rate 10mbit
tc class add dev eth0 parent 1: classid 1:2 htb rate 20mbit
tc filter add dev eth0 parent 1: protocol ip prio 16 u32 match ip dst 1.2.3.4 flowid 1:1
tc filter add dev eth0 parent 1: protocol ip prio 16 u32 match ip dst 2.3.4.5 flowid 1:2
1

I don't know a QDISC that would do that directly. With CBQ/HTB/HFSC, at best you could create a limited number of 10mbps classes and then hash filter IPs into them. Apart from hash collisions which will obviously happen, it would work.

With some luck, you can set such limits directly at the source (like, in the webserver).

But if it's not really about rate limiting, but keeping things fair between clients, maybe you're better off with SFQ/ESFQ. While it does not limit, it does provide a kind of balance.

  • is there a better solution other than TC then that would accomplish this? While not having to create a dedicated VPS for the bandwidth rules? I tried to find TC performance tests that showed benchmarks of ram/cpu usage and couldn't find too many that focused on CPU/ram but rather focused on speed of the packet processing. As far as I could find, TC appears to be the most robust but just doesn't appear to accommodate the exact functionality I'm looking to achieve. I will read up more on the SFQ/ESFQ since you state it's more of a last resort potential solution. – RCG Jan 30 '15 at 0:19
  • Also for CBQ/HTB/HFSC, I've seen examples where they limit per PORT per specific IP. I have firewall rules in place which already limit which ports clients accessing the VPS can establish, what would be a way (if there is one) to write a tc rule for HTB that would accomplish allowing all traffic from one specific IP at x rate regardless of the port? This way I don't have to put in multiple rules per unique IP due to multiple ports they access. – RCG Jan 30 '15 at 0:24
  • Also for buffer issues. I'm wanting to set the buffer accordingly to the cap that I'm going to induce which I believe will be 10mbps. I know on a 1gigabit connection a 1MB buffer will empty in ~7-8 milliseconds, I've read you want to adjust buffers accordingly, however it seems for a 10mbit connection limit the buffer would be roughly then 0.01MB per unique IP, does that sound correct? – RCG Jan 30 '15 at 1:07
  • I ended up testing quite a few configurations as per frostshutz recommendations. I believe I was a bit confused thinking that with HTB, you set a x speed and then all clients you assign to it will share the x speed. This is true, but I did not realize you could create new HTB classes and put each unique IP into a different HTB class. End result running multiple HTB qdiscs that unique IP's can go into. I tried CBQ but believe my numbers weren't correct for the proper cell size etc. I had jittery QoS when doing things like media streaming.(Probably due to dropped packets) HTB works the easiest. – RCG Jan 30 '15 at 4:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.