Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm setting up an environment where I have one Linux server, one OpenBSD router and one Linux client and I want to be able to limit how much bandwidth the client should be able to use.

I've been performing these tests with "netcat" and "time" (using time to measure the time of the transfer with netcat), and what happens when trying these tests (using the TCP protocol, the queues will for some reason not work with UDP) is that the queues aren't exact at all.

For example: when setting a bandwidth limit of 10mbit, the client cannot use more than five mbits, when setting a limit of 100mbit, the client cannot use more than around 50mbit.

The config looks like (using a 100mbit limit in the example):

#queue rules
altq on { $int_if, $ext_if } cbq bandwidth 100Mb queue { def, low }
queue def bandwidth 0Mb cbq(default)
queue low bandwidth 100Mb cbq(default)

#Passrules test

pass out quick from $int_if to $ext_if queue low
pass in quick from $ext_if to $int_if queue low
pass out quick from $ext_if to $int_if queue low
pass in quick from $int_if to $ext_if queue low
share|improve this question

In my experience for altq to work well you really need to add the red, rio or ecn option to your limiting queues, otherwise as you approach saturation (physical or queue-virtual) you're in for some unpleasant situations. Take a look at the section on RED (Random Early Detection) in the altq howto for more info.

Also, two problems with your snippet above:

  1. You have two default queues: This isn't allowed (in fact pf should throw a fit about it).
  2. One of your queues has no bandwidth (0Mb)? -- This is probably not what you wanted/meant...
share|improve this answer
There should indeed not be two default queues; I was testing some different rule setups when setting this up, and modified the current rules I had to what I originally had (I forgot to remove the default parameter from the low-queue). Will look into RED to see if it will solve this. By the way, any ideas regarding why the queues only are applied to TCP connections? The 0Mb limit was basically just there due to that I only wanted to test with one queue; I could indeed only have one queue, though I wanted to test altq with different queues, but did first want to try it for only one queue. – user42511 May 8 '10 at 13:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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