[LARTC] herz the script that i have done.

Linux Advanced Routing and Traffic Control

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

 



Hello there,

 Having made quite a lot of expensive mistakes i have finally clobbered
together a script for the users on my network.

 Have a look at it and please suggest as to how can i limit bandwidth to
each ip on this network to about 64Kbits.

Trevor



-- 
( >-    GNU/LINUX, It's all about CHOICE      -< )
/~\    __  trevor@xxxxxxxxxxxxxxxxxxxxxx  __   /~\
|  \) /  Pre Sales Consultant - Red Hat     \ (/ |
|_|_  \    9820349221(M) | 22881326(O)      / _|_|
       \___________________________________/
#!/bin/bash
                                                                                                                                              
#####################################
#Deleting and setting up
#Root qdisc's
#####################################
tc qdisc del dev eth0 root
tc qdisc add dev eth0 root handle 1:0 cbq bandwidth 1Mbit avpkt 1000 cell 8

#######################################
#Setting up top 2 qdiscs
#for initial packet classification
#######################################
# Exatt Rules
#######################################

tc class add dev eth0 parent 1:0 classid 1:1 cbq bandwidth 1Mbit rate 800kbit weight 80kbit allot 1514 cell 8 maxburst 20 avpkt 1000 isolated
tc filter add dev eth0 parent 1:0 protocol ip u32 match ip src 192.168.10.0/24 classid 1:1
tc filter add dev eth0 parent 1:0 protocol ip u32 match ip dst 192.168.10.0/24 classid 1:1
                                                                         
tc filter add dev eth0 parent 1:0 protocol ip u32 match ip src 192.168.11.0/24 classid 1:1
tc filter add dev eth0 parent 1:0 protocol ip u32 match ip dst 192.168.11.0/24 classid 1:1

tc filter add dev eth0 parent 1:0 protocol ip u32 match ip src 192.168.12.0/24 classid 1:1
tc filter add dev eth0 parent 1:0 protocol ip u32 match ip dst 192.168.12.0/24 classid 1:1

tc filter add dev eth0 parent 1:0 protocol ip u32 match ip src 192.168.13.0/24 classid 1:1
tc filter add dev eth0 parent 1:0 protocol ip u32 match ip dst 192.168.13.0/24 classid 1:1

tc filter add dev eth0 parent 1:0 protocol ip u32 match ip src 192.168.14.0/24 classid 1:1
tc filter add dev eth0 parent 1:0 protocol ip u32 match ip dst 192.168.14.0/24 classid 1:1

tc filter add dev eth0 parent 1:0 protocol ip u32 match ip src 192.168.15.0/24 classid 1:1
tc filter add dev eth0 parent 1:0 protocol ip u32 match ip dst 192.168.15.0/24 classid 1:1

tc filter add dev eth0 parent 1:0 protocol ip u32 match ip src 192.168.16.0/24 classid 1:1
tc filter add dev eth0 parent 1:0 protocol ip u32 match ip dst 192.168.16.0/24 classid 1:1

tc filter add dev eth0 parent 1:0 protocol ip u32 match ip src 192.168.17.0/24 classid 1:1
tc filter add dev eth0 parent 1:0 protocol ip u32 match ip dst 192.168.17.0/24 classid 1:1

tc filter add dev eth0 parent 1:0 protocol ip u32 match ip src 192.168.18.0/24 classid 1:1
tc filter add dev eth0 parent 1:0 protocol ip u32 match ip dst 192.168.18.0/24 classid 1:1

tc filter add dev eth0 parent 1:0 protocol ip u32 match ip src 192.168.19.0/24 classid 1:1
tc filter add dev eth0 parent 1:0 protocol ip u32 match ip dst 192.168.19.0/24 classid 1:1


##########################################
#Paradyne Rules
##########################################                                                                     
tc class add dev eth0 parent 1:0 classid 1:2 cbq bandwidth 1Mbit rate 200kbit weight 20kbit allot 1514 cell 8 maxburst 20 avpkt 1000 bounded
tc filter add dev eth0 parent 1:0 protocol ip u32 match ip src 192.168.20.0/24 classid 1:2
tc filter add dev eth0 parent 1:0 protocol ip u32 match ip dst 192.168.20.0/24 classid 1:2

tc filter add dev eth0 parent 1:0 protocol ip u32 match ip src 192.168.21.0/24 classid 1:2
tc filter add dev eth0 parent 1:0 protocol ip u32 match ip dst 192.168.21.0/24 classid 1:2

tc filter add dev eth0 parent 1:0 protocol ip u32 match ip src 192.168.22.0/24 classid 1:2
tc filter add dev eth0 parent 1:0 protocol ip u32 match ip dst 192.168.22.0/24 classid 1:2

tc filter add dev eth0 parent 1:0 protocol ip u32 match ip src 192.168.23.0/24 classid 1:2
tc filter add dev eth0 parent 1:0 protocol ip u32 match ip dst 192.168.23.0/24 classid 1:2

tc filter add dev eth0 parent 1:0 protocol ip u32 match ip src 192.168.24.0/24 classid 1:2
tc filter add dev eth0 parent 1:0 protocol ip u32 match ip dst 192.168.24.0/24 classid 1:2

tc filter add dev eth0 parent 1:0 protocol ip u32 match ip src 192.168.25.0/24 classid 1:2
tc filter add dev eth0 parent 1:0 protocol ip u32 match ip dst 192.168.25.0/24 classid 1:2

tc filter add dev eth0 parent 1:0 protocol ip u32 match ip src 192.168.26.0/24 classid 1:2
tc filter add dev eth0 parent 1:0 protocol ip u32 match ip dst 192.168.26.0/24 classid 1:2

tc filter add dev eth0 parent 1:0 protocol ip u32 match ip src 192.168.27.0/24 classid 1:2
tc filter add dev eth0 parent 1:0 protocol ip u32 match ip dst 192.168.27.0/24 classid 1:2

tc filter add dev eth0 parent 1:0 protocol ip u32 match ip src 192.168.28.0/24 classid 1:2
tc filter add dev eth0 parent 1:0 protocol ip u32 match ip dst 192.168.28.0/24 classid 1:2

tc filter add dev eth0 parent 1:0 protocol ip u32 match ip src 192.168.29.0/24 classid 1:2
tc filter add dev eth0 parent 1:0 protocol ip u32 match ip dst 192.168.29.0/24 classid 1:2

                                                                                                                                              
#######################################
#Setting up top 10 qdiscs
#for initial Exatt packet classification
#######################################
tc class add dev eth0 parent 1:1 classid 1:3 cbq bandwidth 1Mbit rate 80Kbit allot 1514 cell 8 maxburst 20 avpkt 1000 weight 8Kbit bounded isolated
tc filter add dev eth0 parent 1:1 protocol ip u32 match ip src 192.168.10.0/24 classid 1:3
tc filter add dev eth0 parent 1:1 protocol ip u32 match ip dst 192.168.10.0/24 classid 1:3
                                                                                                                                              
tc class add dev eth0 parent 1:1 classid 1:4 cbq bandwidth 1Mbit rate 80Kbit allot 1514 cell 8 maxburst 20 avpkt 1000 weight 8Kbit bounded isolated
tc filter add dev eth0 parent 1:1 protocol ip u32 match ip src 192.168.11.0/24 classid 1:4
tc filter add dev eth0 parent 1:1 protocol ip u32 match ip dst 192.168.11.0/24 classid 1:4                                                                                
tc class add dev eth0 parent 1:1 classid 1:5 cbq bandwidth 1Mbit rate 80Kbit allot 1514 cell 8 maxburst 20 avpkt 1000 weight 8Kbit bounded isolated
tc filter add dev eth0 parent 1:1 protocol ip u32 match ip src 192.168.12.0/24 classid 1:5
tc filter add dev eth0 parent 1:1 protocol ip u32 match ip dst 192.168.12.0/24 classid 1:5
                                                                                                                                              
tc class add dev eth0 parent 1:1 classid 1:6 cbq bandwidth 1Mbit rate 80Kbit allot 1514 cell 8 maxburst 20 avpkt 1000 weight 8Kbit bounded isolated
tc filter add dev eth0 parent 1:1 protocol ip u32 match ip src 192.168.13.0/24 classid 1:6
tc filter add dev eth0 parent 1:1 protocol ip u32 match ip dst 192.168.13.0/24 classid 1:6
                                                                                                                                              
tc class add dev eth0 parent 1:1 classid 1:7 cbq bandwidth 1Mbit rate 80Kbit allot 1514 cell 8 maxburst 20 avpkt 1000 weight 8Kbit bounded isolated  
tc filter add dev eth0 parent 1:1 protocol ip u32 match ip src 192.168.14.0/24 classid 1:7
tc filter add dev eth0 parent 1:1 protocol ip u32 match ip dst 192.168.14.0/24 classid 1:7
                                                                                                                                              
tc class add dev eth0 parent 1:1 classid 1:8 cbq bandwidth 1Mbit rate 80Kbit allot 1514 cell 8 maxburst 20 avpkt 1000 weight 8Kbit bounded isolated
tc filter add dev eth0 parent 1:1 protocol ip u32 match ip src 192.168.15.0/24 classid 1:8
tc filter add dev eth0 parent 1:1 protocol ip u32 match ip dst 192.168.15.0/24 classid 1:8

tc class add dev eth0 parent 1:1 classid 1:9 cbq bandwidth 1Mbit rate 80Kbit allot 1514 cell 8 maxburst 20 avpkt 1000 weight 8Kbit bounded isolated 
tc filter add dev eth0 parent 1:1 protocol ip u32 match ip src 192.168.16.0/24 classid 1:9
tc filter add dev eth0 parent 1:1 protocol ip u32 match ip dst 192.168.16.0/24 classid 1:9
                                                                                                                                              
tc class add dev eth0 parent 1:1 classid 1:10 cbq bandwidth 1Mbit rate 80Kbit allot 1514 cell 8 maxburst 20 avpkt 1000 weight 8Kbit bounded isolated
tc filter add dev eth0 parent 1:1 protocol ip u32 match ip src 192.168.17.0/24 classid 1:10
tc filter add dev eth0 parent 1:1 protocol ip u32 match ip dst 192.168.17.0/24 classid 1:10
                                                                                                                                              
tc class add dev eth0 parent 1:1 classid 1:11 cbq bandwidth 1Mbit rate 80Kbit allot 1514 cell 8 maxburst 20 avpkt 1000 weight 8Kbit bounded isolated 
tc filter add dev eth0 parent 1:1 protocol ip u32 match ip src 192.168.18.0/24 classid 1:11
tc filter add dev eth0 parent 1:1 protocol ip u32 match ip dst 192.168.18.0/24 classid 1:11
                                                                                                                                              
tc class add dev eth0 parent 1:1 classid 1:12 cbq bandwidth 1Mbit rate 80Kbit allot 1514 cell 8 maxburst 20 avpkt 1000 weight 8Kbit bounded isolated 
tc filter add dev eth0 parent 1:1 protocol ip u32 match ip src 192.168.19.0/24 classid 1:12
tc filter add dev eth0 parent 1:1 protocol ip u32 match ip dst 192.168.19.0/24 classid 1:12
                                 

######################################
#Setting up top 10 qdiscs
#for initial Paradyne packet classification
#######################################
tc class add dev eth0 parent 1:2 classid 1:13 cbq bandwidth 1Mbit rate 80Kbit allot 1514 cell 8 maxburst 20 avpkt 1000 weight 8Kbit bounded 
tc filter add dev eth0 parent 1:2 protocol ip u32 match ip src 192.168.20.0/24 classid 1:13
tc filter add dev eth0 parent 1:2 protocol ip u32 match ip dst 192.168.20.0/24 classid 1:13
                                                                                                             
tc class add dev eth0 parent 1:2 classid 1:14 cbq bandwidth 1Mbit rate 80Kbit allot 1514 cell 8 maxburst 20 avpkt 1000 weight 8Kbit bounded
tc filter add dev eth0 parent 1:2 protocol ip u32 match ip src 192.168.21.0/24 classid 1:14
tc filter add dev eth0 parent 1:2 protocol ip u32 match ip dst 192.168.21.0/24 classid 1:14
                                                                                                                                             
tc class add dev eth0 parent 1:2 classid 1:15 cbq bandwidth 1Mbit rate 80Kbit allot 1514 cell 8 maxburst 20 avpkt 1000 weight 8Kbit bounded
tc filter add dev eth0 parent 1:2 protocol ip u32 match ip src 192.168.22.0/24 classid 1:15
tc filter add dev eth0 parent 1:2 protocol ip u32 match ip dst 192.168.22.0/24 classid 1:15

tc class add dev eth0 parent 1:2 classid 1:16 cbq bandwidth 1Mbit rate 80Kbit allot 1514 cell 8 maxburst 20 avpkt 1000 weight 8Kbit bounded
tc filter add dev eth0 parent 1:2 protocol ip u32 match ip src 192.168.23.0/24 classid 1:16
tc filter add dev eth0 parent 1:2 protocol ip u32 match ip dst 192.168.23.0/24 classid 1:16

tc class add dev eth0 parent 1:2 classid 1:17 cbq bandwidth 1Mbit rate 80Kbit allot 1514 cell 8 maxburst 20 avpkt 1000 weight 8Kbit bounded
tc filter add dev eth0 parent 1:2 protocol ip u32 match ip src 192.168.24.0/24 classid 1:17
tc filter add dev eth0 parent 1:2 protocol ip u32 match ip dst 192.168.24.0/24 classid 1:17

tc class add dev eth0 parent 1:2 classid 1:18 cbq bandwidth 1Mbit rate 80Kbit allot 1514 cell 8 maxburst 20 avpkt 1000 weight 8Kbit bounded
tc filter add dev eth0 parent 1:2 protocol ip u32 match ip src 192.168.25.0/24 classid 1:18
tc filter add dev eth0 parent 1:2 protocol ip u32 match ip dst 192.168.25.0/24 classid 1:18

tc class add dev eth0 parent 1:2 classid 1:19 cbq bandwidth 1Mbit rate 80Kbit allot 1514 cell 8 maxburst 20 avpkt 1000 weight 8Kbit bounded
tc filter add dev eth0 parent 1:2 protocol ip u32 match ip src 192.168.26.0/24 classid 1:19
tc filter add dev eth0 parent 1:2 protocol ip u32 match ip dst 192.168.26.0/24 classid 1:19

tc class add dev eth0 parent 1:2 classid 1:20 cbq bandwidth 1Mbit rate 80Kbit allot 1514 cell 8 maxburst 20 avpkt 1000 weight 8Kbit bounded
tc filter add dev eth0 parent 1:2 protocol ip u32 match ip src 192.168.27.0/24 classid 1:20
tc filter add dev eth0 parent 1:2 protocol ip u32 match ip dst 192.168.27.0/24 classid 1:20

tc class add dev eth0 parent 1:2 classid 1:21 cbq bandwidth 1Mbit rate 80Kbit allot 1514 cell 8 maxburst 20 avpkt 1000 weight 8Kbit bounded
tc filter add dev eth0 parent 1:2 protocol ip u32 match ip src 192.168.28.0/24 classid 1:21
tc filter add dev eth0 parent 1:2 protocol ip u32 match ip dst 192.168.28.0/24 classid 1:21

tc class add dev eth0 parent 1:2 classid 1:22 cbq bandwidth 1Mbit rate 80Kbit allot 1514 cell 8 maxburst 20 avpkt 1000 weight 8Kbit bounded
tc filter add dev eth0 parent 1:2 protocol ip u32 match ip src 192.168.29.0/24 classid 1:22
tc filter add dev eth0 parent 1:2 protocol ip u32 match ip dst 192.168.29.0/24 classid 1:22

                                                                                                                                              
#################################
# Start of Actual Filters
#################################
                                                                                                                                              


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