IP based bandwidth mangement

General discussion about PLUC and Linux in Pakistan.

IP based bandwidth mangement

Postby kernel-trap » Mon Mar 07, 2005 6:48 pm

Dear all

i want to restrict bandwidth on ip like i have 256kbps connection

eth0 Public ip
eth1 Private ip

#-- step 1 -----
tc qdisc add dev eth0 root handle 0: htb default 0:3

#-- step 2 -----
tc class add dev eth0 parent 0: classid 0:1 htb rate 128kbit ceil 128kbit
tc class add dev eth0 parent 0: classid 0:2 htb rate 128kbit ceil 128kbit
tc class add dev eth0 parent 0: classid 0:3 htb rate 10Mbit ceil 10Mbit


#-- step 3 -----
tc filter add dev eth0 protocol ip parent 0:0 prio 1 u32 \
match ip dst 10.0.0.1 flowid 0:1

tc filter add dev eth0 protocol ip parent 0:0 prio 1 u32 \
match ip dst 10.0.0.2 flowid 0:2


#-- repeat for other direction -----

tc qdisc add dev eth1 root handle 1: htb default 1:3
tc class add dev eth1 parent 1: classid 1:1 htb rate 128kbit ceil 128kbit
tc class add dev eth1 parent 1: classid 1:2 htb rate 128kbit ceil 128kbit
tc class add dev eth1 parent 1: classid 1:3 htb rate 10Mbit ceil 10Mbit

tc filter add dev eth1 protocol ip parent 1:0 prio 1 u32 \
match ip src 10.0.0.1 flowid 1:1

tc filter add dev eth1 protocol ip parent 1:0 prio 1 u32 \
match ip src 10.0.0.2 flowid 1:2

this is not tested yet boz i am no linux box right now any comment will be helpful

REGARDS
kernel-trap
Havaldaar
 
Posts: 105
Joined: Thu Dec 25, 2003 2:31 pm

Return to “%s” General

Who is online

Users browsing this forum: No registered users and 1 guest

cron