Hi i send this script that i build for ADSL
512Kbps Downstream
128Kbps Upstream
It works perfect but i have a problem with the WWW badnwidth management.
I am using bering 1.2 for NAT Router. So i cant''t use IMQ.
Well the problem in fact is that i prioritize the ACK, ICMP, DNS, TELNET,
Counter Strike
and the most important WWW (well here is the problem).
If anybody on my network start downloading with something like DAP (Download
Accelerator)
then it consume the total bandwidth. The idea is that for small www access
it use this class but
for large download use other class. This the policy i''m useing for mark
the
www access to internet.
############################################################################
#
# WWW
iptables -t mangle -A PREROUTING -p tcp --sport 80 \
-j MARK --set-mark 8
############################################################################
#
tc filter add dev eth0 parent 1: protocol ip prio 3 handle 8 fw
flowid 1:13
tc class add dev eth0 parent 1:1 classid 1:13 htb rate 30kbps ceil
$BW burst 3k prio 2
I was thinking to set down the
rate 30Kbps ceil 56Kbps ($BW)
to
rate 15Kbps ceil 30Kbps
but this is not the best performance.
So, anybody know how to catch the large package to www port?
Thanks in advance, and i hope this script help you.
Sebastian A. Aresca
#! /bin/sh
#
############################################################################
#
# Parametros
#
############################################################################
#
# r2q = lower_rate / 1500
#R2Q=15
# Total Bandwidth
BW=56Kbps
OUTBW=14Kbps
# Definicion de clase padre
tc qdisc del dev eth0 root
tc qdisc del dev eth0 ingress
iptables -t mangle -F
if [ "$1" = "stop" ]
then
echo ''Stop''
exit
fi
tc qdisc add dev eth0 root handle 1: htb default 19
############################################################################
#
# Clases
#
############################################################################
#
tc class add dev eth0 parent 1: classid 1:1 htb rate $BW ceil $BW
# Max prioridad (dns, icmp, ack, telnet, sshd)
tc class add dev eth0 parent 1:1 classid 1:10 htb rate $BW ceil $BW burst 3k
prio 0
# Counter Strike
tc class add dev eth0 parent 1:1 classid 1:11 htb rate $BW ceil $BW burst 3k
prio 1
# Terminals
tc class add dev eth0 parent 1:1 classid 1:12 htb rate 40kbps ceil $BW
burst 3k prio 2
# Ports
tc class add dev eth0 parent 1:1 classid 1:13 htb rate 30kbps ceil $BW burst
3k prio 2
# Others
tc class add dev eth0 parent 1:1 classid 1:19 htb rate 15kbps ceil $BW burst
3k prio 3
############################################################################
#
############################################################################
#
# SFQ Queueing
tc qdisc add dev eth0 parent 1:11 handle 11: sfq perturb 10
tc qdisc add dev eth0 parent 1:12 handle 12: sfq perturb 10
tc qdisc add dev eth0 parent 1:13 handle 13: sfq perturb 10
tc qdisc add dev eth0 parent 1:19 handle 19: sfq perturb 10
############################################################################
#
############################################################################
#
# Filters
#
############################################################################
#
# IPTABLES
tc filter add dev eth0 parent 1: protocol ip prio 1 handle 2 fw flowid 1:10
tc filter add dev eth0 parent 1: protocol ip prio 2 handle 9 fw flowid 1:11
tc filter add dev eth0 parent 1: protocol ip prio 3 handle 3 fw flowid 1:12
tc filter add dev eth0 parent 1: protocol ip prio 3 handle 8 fw flowid 1:13
############################################################################
######################################
# PORTS Filters
############################################################################
#
# ICMP
iptables -t mangle -A PREROUTING -p icmp \
-j MARK --set-mark 1
iptables -t mangle -A OUTPUT -p icmp \
-j MARK --set-mark 2
iptables -t mangle -A PREROUTING -p icmp -j RETURN
iptables -t mangle -A OUTPUT -p icmp -j RETURN
############################################################################
#
############################################################################
#
# Telnet
iptables -t mangle -A PREROUTING -p tcp --sport 23 \
-j MARK --set-mark 1
iptables -t mangle -A OUTPUT -p tcp --sport 23 \
-j MARK --set-mark 1
iptables -t mangle -A PREROUTING -p tcp --sport 23 -j RETURN
iptables -t mangle -A OUTPUT -p tcp --sport 23 -j RETURN
############################################################################
#
############################################################################
#
# SSH
iptables -t mangle -A PREROUTING -p tcp --sport 22 \
-j MARK --set-mark 1
iptables -t mangle -A OUTPUT -p tcp --sport 22 \
-j MARK --set-mark 1
iptables -t mangle -A PREROUTING -p tcp --sport 22 -j RETURN
iptables -t mangle -A OUTPUT -p tcp --sport 22 -j RETURN
############################################################################
#
############################################################################
#
# DNS
iptables -t mangle -A PREROUTING -p udp --sport 53 \
-j MARK --set-mark 1
#iptables -t mangle -A OUTPUT -p udp --sport 53 \
TESTING
# -j MARK --set-mark 1
iptables -t mangle -A PREROUTING -p udp --sport 53 -j RETURN
#iptables -t mangle -A OUTPUT -p udp --sport 53 -j RETURN
############################################################################
#
############################################################################
#
# WWW
iptables -t mangle -A PREROUTING -p tcp --sport 80 \
-j MARK --set-mark 8
############################################################################
#
############################################################################
#
# Counter Strike Ports
iptables -t mangle -A PREROUTING -p udp --dport 27010:27019 \
-j MARK --set-mark 9
iptables -t mangle -A PREROUTING -p udp --sport 27010:27019 -j
RETURN
############################################################################
#
############################################################################
######################################
############################################################################
######################################
# PC Filters
# PC firewall
# iptables -t mangle -A OUTPUT -s 192.168.0.101 \
# -j MARK --set-mark 1
# PC funcomputer2
# iptables -t mangle -A POSTROUTING -o eth0 -d 192.168.0.1 \
# -j MARK --set-mark 11
# PC funcomputer1
# iptables -t mangle -A POSTROUTING -o eth0 -d 192.168.0.3 \
# -j MARK --set-mark 13
# PC wkswindowsxp
iptables -t mangle -A PREROUTING -s 192.168.1.4 \
-j MARK --set-mark 3
############################################################################
######################################
############################################################################
#
# Results
#
############################################################################
#
#echo ''Cola:''
#tc qdisc show dev eth0
#echo ''''
#echo ''''
#echo ''Clases:''
#tc class show dev eth0
#echo ''''
#echo ''''
echo ''Filtros:''
tc filter show dev eth0
############################################################################
#
# OUT
#
############################################################################
#
tc qdisc add dev eth0 handle ffff: ingress
tc filter add dev eth0 parent ffff: protocol ip prio 1 u32 match ip \
src 0.0.0.0 police rate $OUTBW burst 3k drop flowid :1
_______________________________________________
LARTC mailing list / LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/