#!/bin/bash
PATH="/sbin:/bin:/usr/sbin:/usr/bin"
TC="/usr/sbin/tc"
IP="/usr/sbin/iptables"
BURST=5Kb
RATE=100
CEIL=3000
CEIL_INTERNAL=7000
CEIL_ADMIN=3000
CEIL_ADMIN_SSH=500
let "CEIL_MAIN=$CEIL_INTERNAL+$CEIL"
let "CEIL_MAIN2=2*($CEIL_INTERNAL+$CEIL)"
let "CEIL_INTERNAL2=2 * $CEIL_INTERNAL"
let "CEIL2=2 * $CEIL"
let "RATE_MAIN=$RATE * 3"
$IP -t mangle -F
#начало секции br0
$TC qdisc del dev br0 root
$TC qdisc add dev br0 root handle 1: htb default 500
$TC class add dev br0 parent 1: classid 1:1 htb rate 50Mbit
$TC class add dev br0 parent 1:1 classid 1:30 htb rate 40Mbit prio 1
$TC class add dev br0 parent 1:1 classid 1:40 htb rate ${RATE}Kbit ceil ${CEIL_ADMIN_SSH}Kbit prio 1 burst ${BURST}
$TC class add dev br0 parent 1:1 classid 1:50 htb rate ${RATE}Kbit ceil ${CEIL_ADMIN}Kbit prio 2 burst ${BURST}
$TC class add dev br0 parent 1:1 classid 1:60 htb rate ${RATE}Kbit ceil ${CEIL}Kbit prio 2 burst ${BURST}
$TC class add dev br0 parent 1:1 classid 1:70 htb rate ${RATE}Kbit ceil ${CEIL}Kbit prio 2 burst ${BURST}
$TC class add dev br0 parent 1:1 classid 1:80 htb rate ${RATE}Kbit ceil ${CEIL}Kbit prio 2 burst ${BURST}
$TC class add dev br0 parent 1:1 classid 1:90 htb rate ${RATE}Kbit ceil ${CEIL}Kbit prio 2 burst ${BURST}
$TC class add dev br0 parent 1:1 classid 1:100 htb rate ${RATE}Kbit ceil ${CEIL}Kbit prio 2 burst ${BURST}
$TC class add dev br0 parent 1:1 classid 1:110 htb rate ${RATE}Kbit ceil ${CEIL}Kbit prio 2 burst ${BURST}
$TC class add dev br0 parent 1:1 classid 1:120 htb rate ${RATE}Kbit ceil ${CEIL}Kbit prio 2 burst ${BURST}
$TC class add dev br0 parent 1:1 classid 1:130 htb rate ${RATE}Kbit ceil ${CEIL_ADMIN}Kbit prio 2 burst ${BURST}
$TC class add dev br0 parent 1:1 classid 1:140 htb rate ${RATE_MAIN}Kbit ceil ${CEIL_MAIN}Kbit prio 2 burst ${BURST}
$TC class add dev br0 parent 1:140 classid 1:141 htb rate ${RATE}Kbit ceil ${CEIL_ADMIN}Kbit prio 2 burst ${BURST}
$TC class add dev br0 parent 1:140 classid 1:142 htb rate ${RATE}Kbit ceil ${CEIL_INTERNAL}Kbit prio 3
$TC class add dev br0 parent 1:1 classid 1:150 htb rate ${RATE_MAIN}Kbit ceil ${CEIL_MAIN}Kbit prio 2 burst ${BURST}
$TC class add dev br0 parent 1:150 classid 1:151 htb rate ${RATE}Kbit ceil ${CEIL}Kbit prio 2 burst ${BURST}
$TC class add dev br0 parent 1:150 classid 1:152 htb rate ${RATE}Kbit ceil ${CEIL_INTERNAL}Kbit prio 3
#$TC class add dev br0 parent 1:1 classid 1:500 htb rate 1Kbit prio 5
$TC qdisc add dev br0 parent 1:30 handle 30: sfq perturb 10
$TC qdisc add dev br0 parent 1:40 handle 40: sfq perturb 10
$TC qdisc add dev br0 parent 1:50 handle 50: sfq perturb 10
$TC qdisc add dev br0 parent 1:60 handle 60: sfq perturb 10
$TC qdisc add dev br0 parent 1:70 handle 70: sfq perturb 10
$TC qdisc add dev br0 parent 1:80 handle 80: sfq perturb 10
$TC qdisc add dev br0 parent 1:90 handle 90: sfq perturb 10
$TC qdisc add dev br0 parent 1:100 handle 100: sfq perturb 10
$TC qdisc add dev br0 parent 1:110 handle 110: sfq perturb 10
$TC qdisc add dev br0 parent 1:120 handle 120: sfq perturb 10
$TC qdisc add dev br0 parent 1:130 handle 130: sfq perturb 10
$TC qdisc add dev br0 parent 1:141 handle 141: sfq perturb 10
$TC qdisc add dev br0 parent 1:142 handle 142: sfq perturb 10
$TC qdisc add dev br0 parent 1:151 handle 151: sfq perturb 10
$TC qdisc add dev br0 parent 1:152 handle 152: sfq perturb 10
#$TC qdisc add dev br0 parent 1:500 handle 500: pfifo
$TC filter add dev br0 protocol ip parent 1:0 prio 2 u32 match ip dst 192.168.0.0/16 match ip src 192.168.0.0/16 flowid 1:30
$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip sport 22 0xffff flowid 1:40
$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip dport 22 0xffff flowid 1:40
$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip protocol 1 0xff flowid 1:40
$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.200 flowid 1:50
$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.199 flowid 1:50
$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.53 flowid 1:60
$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.131 flowid 1:70
$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.204 flowid 1:80
$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.205 flowid 1:90
$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.40 flowid 1:100
$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.93 flowid 1:100
$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.92 flowid 1:100
$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.59 flowid 1:110
#$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.59 flowid 1:110
#$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.59 flowid 1:110
$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.209 flowid 1:120
$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.206 flowid 1:130
$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.207 match ip src 91.144.140.0/22 flowid 1:142
$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.207 match ip src 91.144.188.0/24 flowid 1:142
$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.207 match ip src 188.187.240.0/24 flowid 1:142
$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.207 match ip src 92.255.192.0/19 flowid 1:142
$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.207 match ip src 94.180.128.0/17 flowid 1:142
$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.207 match ip src 109.195.112.0/2 flowid 1:142
$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.207 flowid 1:141
$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.197 match ip src 91.144.140.0/22 flowid 1:152
$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.197 match ip src 91.144.188.0/24 flowid 1:152
$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.197 match ip src 188.187.240.0/24 flowid 1:152
$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.197 match ip src 92.255.192.0/19 flowid 1:152
$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.197 match ip src 94.180.128.0/17 flowid 1:152
$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.197 match ip src 109.195.112.0/2 flowid 1:152
$TC filter add dev br0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.0.197 flowid 1:151
#конец секции br0
#секция ppp0
$TC qdisc del dev ppp0 root
$TC qdisc add dev ppp0 root handle 1 htb default 2 r2q 10
$TC class add dev ppp0 parent 1: classid 1:1 htb rate 10Mbit
#other (default)
$TC class add dev ppp0 parent 1:1 classid 1:2 htb rate ${RATE}Kbit ceil 9000Kbit prio 4 burst ${BURST}
$TC qdisc add dev ppp0 parent 1:2 handle 2 sfq perturb 10
#admin_ssh
$TC class add dev ppp0 parent 1:1 classid 1:3 htb rate ${RATE}Kbit ceil ${CEIL_ADMIN_SSH}Kbit prio 1 burst ${BURST}
$TC qdisc add dev ppp0 parent 1:3 handle 3 sfq perturb 10
$TC filter add dev ppp0 protocol ip parent 1:0 prio 1 u32 match ip sport 22 0xffff flowid 1:3
$TC filter add dev ppp0 protocol ip parent 1:0 prio 1 u32 match ip dport 22 0xffff flowid 1:3
$TC filter add dev ppp0 protocol ip parent 1:0 prio 1 u32 match ip protocol 1 0xff flowid 1:3
#web
$TC class add dev ppp0 parent 1:1 classid 1:4 htb rate ${RATE}Kbit ceil 9000Kbit prio 2 burst ${BURST}
$TC qdisc add dev ppp0 parent 1:4 handle 4 sfq perturb 10
$TC filter add dev ppp0 protocol ip parent 1:0 prio 1 u32 match ip sport 80 0xffff flowid 1:4
$TC filter add dev ppp0 protocol ip parent 1:0 prio 1 u32 match ip dport 80 0xffff flowid 1:4
#internal
$TC class add dev ppp0 parent 1:1 classid 1:5 htb rate ${RATE}Kbit ceil ${CEIL_INTERNAL}Kbit prio 5
$TC qdisc add dev ppp0 parent 1:5 handle 5 sfq perturb 10
$TC filter add dev ppp0 protocol ip parent 1:0 prio 1 u32 match ip dst 91.144.140.0/22 flowid 1:5
$TC filter add dev ppp0 protocol ip parent 1:0 prio 1 u32 match ip dst 91.144.188.0/24 flowid 1:5
$TC filter add dev ppp0 protocol ip parent 1:0 prio 1 u32 match ip dst 188.187.240.0/24 flowid 1:5
$TC filter add dev ppp0 protocol ip parent 1:0 prio 1 u32 match ip dst 92.255.192.0/19 flowid 1:5
$TC filter add dev ppp0 protocol ip parent 1:0 prio 1 u32 match ip dst 94.180.128.0/17 flowid 1:5
$TC filter add dev ppp0 protocol ip parent 1:0 prio 1 u32 match ip dst 109.195.112.0/20 flowid 1:5
#конец секции ppp0
echo "shaper"
Add a code snippet to your website: www.paste.org