[LARTC] Controlling outgoing bandwidt based on port number.

Linux Advanced Routing and Traffic Control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi to all,

Currently, my server is acting as both a web and mail server.

What I'm trying to do is to restrict the amount of relaying mail
traffics out from my server while the rest (web, ftp etc ...) still
enjoy the full bandwidth.

I'm a newbies in this traffic controlling stuffs and hope you can point
out the errors in my flags ...

Here's the tc commands I've modified from Adv-Routing-HOWTO example:-

tc qdisc add dev eth0 root handle 1: cbq bandwidth 10Mbit allot 1514 cell 8
avpkt 1000 mpu 64
tc class add dev eth0 parent 1: classid 1:1 cbq bandwidth 10Mbit rate 10Mbit
allot 1514 cell 8 weight 1Mbit prio 8 maxburst 20 avpkt 1000
tc class add dev eth0 parent 1:1 classid 1:2 cbq bandwidth 128Kbit rate
128Kbit allot 1514 cell 8 weight 12Kbit prio 3 maxburst 20 avpkt 1000 split
1:0 bounded
tc class add dev eth0 parent 1:1 classid 1:3 cbq bandwidth 10Mbit rate
10Mbit allot 1514 cell 8 weight 1Mbit prio 7 maxburst 20 avpkt 1000 split
1:0 bounded
tc filter add dev eth0 parent 1: prio 3 protocol ip u32
tc filter add dev eth0 parent 1: prio 3 u32 match tcp dst 0x0019 0xffff
match ip protocol 0x6 0xff flowid 1:2

Does the above sequences make any sense?

I believe the problem lies in the last line. I was trying to match all
outgoing traffic destined for port 25.
However, I tried sending a large attachment (abt. 1.2MB) and it reaches my
external mail server
using the full bandwidth (took abt. 30secs).

So I did a little debugging and change the last line to
tc filter add dev eth0 parent 1: prio 3 u32 match ip dst 10.0.0.0/24 flowid
1:2
( here all traffic going to my internal network get throttled )

I tried retrieving a file via http and true enough, the traffic control
works. I can only download
the file at the rate of 15.0KB/Sec (according to IE 5). 15 * 8 = 120. So I
suppose my 128Kbit
bandwidth is working perfectly.

So I think the problem lies in this command

tc filter add dev eth0 parent 1: prio 3 u32 match tcp dst 0x0019 0xffff
match ip protocol 0x6 0xff flowid 1:2

Can someone help me with my filtering rule? I tried all combination but it
just doesn't seem to work.

thanks for your attention.

cheers!
/shaoming






[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux