#!/bin/sh IPTABLES=/sbin/iptables TC=/sbin/tc DEV=eth0 DEVBWDTH=100mbit HOSTS_LIST="192.168.1.2 192.168.1.3 192.168.1.4 192.168.1.5 192.168.1.6 192.168.1.7 192.168.1.8 192.168.1.9 192.168.1.10 192.168.1.11 192.168.1.12 192.168.1$ NM=17 LIMIT_UP=16Kbit LIMIT_UP_WEIGHT=2Kbit UPMARK=26 LOCALSUBNET=192.168.1.0/24 #!/bin/sh if [ "$1" = "A" ] then #UPLOAD $TC qdisc add dev $DEV root handle 15: cbq bandwidth $DEVBWDTH avpkt 1000 mpu 64 for i in $HOSTS_LIST do IP=$(echo $i | awk -F '.' '{print $4}') $TC class add dev $DEV parent 15:0 classid 15:$NM$IP cbq rate $LIMIT_UP weight $LIMIT_UP_WEIGHT allot 1514 prio 1 avpkt 1000 bounded $TC filter add dev $DEV parent 15:0 protocol ip handle $UPMARK$IP fw flowid 15:$NM$IP $IPTABLES -t mangle -$1 PREROUTING -d ! $LOCALSUBNET -s $i -j MARK --set-mark $UPMARK$IP echo " - Limited hosts $i upload to $LIMIT_UP" done fi if [ "$1" = "D" ] then for i in $HOSTS_LIST # $WHO do IP=$(echo $i | awk -F '.' '{print $4}') $IPTABLES -t mangle -$1 PREROUTING -d ! $LOCALSUBNET -s $i -j MARK --set-mark $UPMARK$IP 2> /dev/null > /dev/null $TC filter del dev $DEV parent 15:0 protocol ip handle $UPMARK$IP fw flowid 15:$NM$IP $TC class del dev $DEV parent 15:0 classid 15:$NM$IP cbq rate $LIMIT_UP weight $LIMIT_UP_WEIGHT allot 1514 prio 1 avpkt 1000 bounded echo " - Deleted host $i from upload limit" done #$TC qdisc add dev $DEV root handle 15: cbq bandwidth $DEVBWDTH avpkt 1000 mpu 64 fi