LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   traffic shapping on centos/redhat (https://www.linuxquestions.org/questions/linux-networking-3/traffic-shapping-on-centos-redhat-911807/)

timmy_sunter 11-04-2011 04:53 AM

traffic shapping on centos/redhat
 
Dear all linux guru,

need your guys help really bad.

this i my first post.
and i need help regarding traffic shapping to my web server.

so basicly i can't do this straight to my production server(redhat)
so i build my staging server on my vmware(centos)

what i want to achieve is:
ip range A (which may more than 1 range) limit max bandwidth to 1M
ip range B (which may more than 1 range) limit max bandwidth to 2M

i manage to limit the whole network interface for ip range A to max 1M using tc, but when it accessed by more than 1 user, the speed will be divided, which is wrong.

do you guys have any pointer with iptables?
i tried with mod_bandwidth -> no luck

please please please help me
thanks a lot!!!!

fukawi1 11-04-2011 05:42 AM

http://lartc.org/howto/ explains the process quite well using iptables and tc.

timmy_sunter 11-09-2011 08:06 PM

Anyone can help me?

i configured 1 test file to config the TC and HTB but it's not working

#!/bin/sh
#
# Incoming traffic control
#
CT_IP1="10.1.1.0/24"
CT_IP2="192.168.1.0/24"
DEV=eth1
#
tc qdisc del dev $DEV root
#
tc qdisc add dev $DEV root handle 1: htb default 10
#
tc class add dev $DEV parent 1: classid 1:1 htb rate 10000mbit burst 15k
tc class add dev $DEV parent 1:1 classid 1:10 htb rate 2.5mbps ceil 10mbit burst 15k
tc class add dev $DEV parent 1:1 classid 1:20 htb rate 5mbps ceil 20mbit burst 15k
tc class add dev $DEV parent 1:1 classid 1:30 htb rate 30mbit ceil 30mbit burst 15k
#
tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10
tc qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10
tc qdisc add dev $DEV parent 1:30 handle 30: sfq perturb 10
#
if [ ! -z $CT_IP1 ]; then
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 match ip dst "$CT_IP1" flowid 1:10
fi
if [ ! -z $CT_IP2 ]; then
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 match ip dst "$CT_IP2" flowid 1:20
fi
#
echo;echo "tc configuration for $DEV:"
tc qdisc show dev $DEV
tc class show dev $DEV
tc filter show dev $DEV
#
# Outgoing traffic control
#
DEV=eth1
#
tc qdisc del dev $DEV root
#
tc qdisc add dev $DEV root handle 1: htb default 10
#
tc class add dev $DEV parent 1: classid 1:1 htb rate 10000mbit burst 15k
tc class add dev $DEV parent 1:1 classid 1:10 htb rate 5mbps ceil 10mbit burst 15k
tc class add dev $DEV parent 1:1 classid 1:20 htb rate 10mbps ceil 20mbit burst 15k
tc class add dev $DEV parent 1:1 classid 1:30 htb rate 30mbit ceil 30mbit burst 15k
#
tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10
tc qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10
tc qdisc add dev $DEV parent 1:30 handle 30: sfq perturb 10
#
if [ ! -z $CT_IP1 ]; then
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 match ip src "$CT_IP1" flowid 1:10
fi
if [ ! -z $CT_IP2 ]; then
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 match ip src "$CT_IP2" flowid 1:20
fi
#
echo;echo "tc configuration for $DEV:"
tc qdisc show dev $DEV
tc class show dev $DEV
tc filter show dev $DEV


All times are GMT -5. The time now is 11:25 AM.