Traffic Shaping on CENTOS 5.5

Issues related to configuring your network
Post Reply
ynos
Posts: 3
Joined: 2010/07/08 23:11:50

Traffic Shaping on CENTOS 5.5

Post by ynos » 2010/07/09 00:26:18

Hi all,

I have created a Linux Router using centos 5.5 using netfilter (IPTABLES). My router is a three-leg router. one leg for ISP connection, the other leg for my LAN and the last leg for my DMZ.

The router is working fine as I expected but now I have another requirement. Due to my limited bandwidth (1Mbps) I need a way to shape it. The idea is to give a dedicated 512Kbps of bandwidth for my web server and the other half for my LAN. The LAN should not exceed the 512Kbps bandwidth.

I have searched google and found 'tc' and 'htb' for bandwidth shaping but most of the documentations I found only pertains to 2.2/2.4 kernels and I am now using CentOS release 5.5 (Final) with kernel 2.6.18-164.11.1.el5

First thing is, do I have to patch my kernel to support traffic shaping/QoS or is it already supported?

I have visited these two websites - http://luxik.cdi.cz/~devik/qos/htb/ and http://lartc.org/ and many other websites but there are no documentations whatsoever on how to install tc and/or htb on 2.6 kernels.

As I understand, the 'tc' is included on the 'iproute2' package. By running 'rpm -ql iproute' I confirmed that 'tc' is installed in '/sbin/tc' but how about 'htb'? There is also a man page for tc-htb in '/usr/share/man/man8/tc-htb.8.gz', is 'htb' already included with 'tc' or do I have to install a package like 'htb-tools' as I've seen on the net?

Also, is tc and htb the most ideal way to shape bandwidth through a linux machine?

Thanks in advance!

molson
Posts: 6
Joined: 2006/02/21 02:52:04

Re: Traffic Shaping on CENTOS 5.5

Post by molson » 2010/07/09 20:17:56

Ynos,

I have used htb-gen alot. I have a 23 year old son that will stay up 24/7/365 and play video games. I have limited him to 56k. I also use this in my work network. I limit the bandwidth offenders (Myspace, Facebook, etc) to 128k. I know this is draconian, but work needs to get done, and the kid needs a job. This program will do what you need. I have this running on CentOS 5.5 and it runs perfectly.

Good Luck,

molson

ynos
Posts: 3
Joined: 2010/07/08 23:11:50

Re: Traffic Shaping on CENTOS 5.5

Post by ynos » 2010/07/12 07:36:52

Thanks for the reply.

I'm currently googling this HTB-Gen. It seems to be a front-end for tc and htb.

Guys, please keep the suggestions coming...

Thanks in advance.

User avatar
dfateyev
Posts: 34
Joined: 2009/11/15 03:34:01
Location: Kostanay, Kazakhstan
Contact:

Re: Traffic Shaping on CENTOS 5.5

Post by dfateyev » 2010/07/14 04:52:32

Also you may use examples from LARTC (you've mentioned above), this is a good example: http://lartc.org/howto/lartc.cookbook.fullnat.intro.html

You just need to create your own classes (e.g., one class for each client), set `rate` and and `ceil` for each of them, classify them with ip-marks and then mark all traffic from client with iptables MARK actions to match with appropriate queue.

The HTB rules are very flexible, so you may write your own set as you wish. You may limit your clients with many criteria (protocols, ports, source/dest. addresses, ranges.) The simplest approach, as I said, is to limit each client with fixed bandwidth with the possibility of borrowing unused bandwidth from others.

That article was intended for kernel-2.4. but working flawlessly with any 2.6.x, too.

yyagol
Posts: 1015
Joined: 2006/06/10 18:27:44
Location: 32 4′N 34 47′E
Contact:

Re: Traffic Shaping on CENTOS 5.5

Post by yyagol » 2010/07/15 05:38:14

I used tc allot , there are lots of graphical interfaces you can use
for example http://www.mastershaper.org/index.php/MasterShaper

ynos
Posts: 3
Joined: 2010/07/08 23:11:50

Re: Traffic Shaping on CENTOS 5.5

Post by ynos » 2010/07/15 13:14:36

Thanks for the reply guys...

@denf
do I need to install something or patch my kernel to use the tc command on my 2.6.x kernel?

@yyagol
GUI are nice to have and easy to use but I prefer to go the long way via console. If I know how to work things on the console, I will also know how to troubleshoot them. But I can't also just close ignore the graphs generated by the Web GUI.

Again, thanks a million....

User avatar
dfateyev
Posts: 34
Joined: 2009/11/15 03:34:01
Location: Kostanay, Kazakhstan
Contact:

Re: Traffic Shaping on CENTOS 5.5

Post by dfateyev » 2010/07/16 10:45:33

[quote]
ynos wrote:
Thanks for the reply guys...

@denf
do I need to install something or patch my kernel to use the tc command on my 2.6.x kernel?
[/quote]
You need to have only [i]`iproute`[/i] package installed. That's all.
The HTB support is already implemented in centos kernel.

Post Reply