HTB -GEN no segmenta el Upstream

Imagen de micronic

Forums: 

Hola amigos! :) Configure HTB-GEN segun lo comentaban aqui en el foro (http://www.ecualug.org/?q=2007/08/22/comos/como_controlar_el_ancho_de_banda_usando_htbgen) y funciono perfectamente exepto por la segmentacion del Upstream.
Sin la configuracion de HTB en www.speedtest.net me marcaga el total de mi ancho de banda (1500k Descarga y 128k de subida), despues de la configuracion me marcaba exactamente lo que yo le asigne de velocidad maxima de descarga(128k de Descarga), pero me seguia marcando 128k de subida cuando yo le asigne 64k de subida? :( que se puede hacer? estube buscando pero no encontre anda.
al hacer:
# iptables -nL -t mangle

Chain PREROUTING (policy ACCEPT)
target prot opt source destination

Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination
htb-gen.down all -- 0.0.0.0/0 0.0.0.0/0
htb-gen.up all -- 0.0.0.0/0 0.0.0.0/0

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
htb-gen.down all -- 0.0.0.0/0 0.0.0.0/0

Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
htb-gen.up all -- 0.0.0.0/0 0.0.0.0/0

Chain htb-gen.down (2 references)
target prot opt source destination
htb-gen.down-192.168.10.2 all -- 0.0.0.0/0 192.168.10.2

Chain htb-gen.down-192.168.10.2 (1 references)
target prot opt source destination
MARK all -- 0.0.0.0/0 0.0.0.0/0 MARK match 0x0 length 0:100 MARK set 0x1b5b
MARK udp -- 0.0.0.0/0 0.0.0.0/0 MARK match 0x0 MARK set 0x1b5b
MARK icmp -- 0.0.0.0/0 0.0.0.0/0 MARK match 0x0 MARK set 0x1b5b
MARK tcp -- 0.0.0.0/0 0.0.0.0/0 MARK match 0x0 multiport sports 20,21,22,25,80,110,143,443,465,993,995,1863,1864,3389,3128 MARK set 0x1b5b
MARK all -- 0.0.0.0/0 0.0.0.0/0 MARK match 0x0 helper match "ftp" MARK set 0x1b5b
MARK all -- 0.0.0.0/0 0.0.0.0/0 MARK match 0x0 MARK set 0x1b5c
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0

Chain htb-gen.up (2 references)
target prot opt source destination
htb-gen.up-192.168.10.2 all -- 192.168.10.2 0.0.0.0/0

Chain htb-gen.up-192.168.10.2 (1 references)
target prot opt source destination
MARK all -- 0.0.0.0/0 0.0.0.0/0 MARK match 0x0 length 0:100 MARK set 0x1b5e
MARK udp -- 0.0.0.0/0 0.0.0.0/0 MARK match 0x0 MARK set 0x1b5e
MARK icmp -- 0.0.0.0/0 0.0.0.0/0 MARK match 0x0 MARK set 0x1b5e
MARK tcp -- 0.0.0.0/0 0.0.0.0/0 MARK match 0x0 multiport dports 20,21,22,25,80,110,143,443,465,993,995,1863,1864,3389,3128 MARK set 0x1b5e
MARK all -- 0.0.0.0/0 0.0.0.0/0 MARK match 0x0 helper match "ftp" MARK set 0x1b5e
MARK all -- 0.0.0.0/0 0.0.0.0/0 MARK match 0x0 MARK set 0x1b5f
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0

GRacias de antemano Suerte!

En un algun lado del COMO se

Imagen de damage

En un algun lado del COMO se explica se use debe hacer unos cambios en el /usr/bin/htb-gen, adicionando unas lineas de OUTPUT para la bajada y de POSTROUTING para la subida, todo es ir jugando con estas lineas, igual pegale una leida a un manual de iptables y el de LARTC para que tengas idea de que hacer si no comprenderas nada.
Aunque a mi me funciona solo con el FORWARD y OUTPUT de bajada y solo el FORWARD de subida y anda bien segmenta de manera normal y tengo squid + firewall de iptables + htb-gen y son varios server asi.

Keep The Fire Burning.....
Stryper 1988

Hice todo tal cual dice el COMO y no logro segmentar el upstream

Imagen de micronic

Hola! hice todo tal cual, y no encuentro la manera de solucionar el problema, la velocidad de subida no me la segmenta, dejo lo que hice en el archivo: /usr/bin/htb-gen

#!/bin/bash
# Program: htb-gen
# Version: 0.8.4
# Description: Script to automate multi host bandwidth managment
# URL: http://www.freshmeat.net/projects/htb-gen/
# Author: Luciano Ruete
# License: GPLv2+
#
#Script begins --here!-- don't touch bellow this line... but, if you do, mail me! :-)
source "/etc/htb-gen/htb-gen.conf"
test -r $htb_gen_rates_conf || { echo "rates config file not found: $htb_gen_rates_conf" && exit 1; }

#easy path adaptation
function iptables () { ${iptables_command:="/sbin/iptables"} "$@"; }
function iptables-save () { ${iptables_save_command:="/sbin/iptables-save"} "$@"; }
function iptables-restore () { ${iptables_restore_command:="/sbin/iptables-restore"} "$@"; }
function tc () { ${tc_command:="/sbin/tc"} "$@"; }

function load_conf () { #loads htb-gen-rates.conf in global vars for furter use
local n=0 line= total_ceil_down=0 total_ceil_up=0 _total_rate_down=$total_rate_down _total_rate_up=$total_rate_up
while read line ;do
#read -a & ${line[x]} is another way, but this is eye cleanner :-)
set -- $line
test -z "${1##\#*}" && continue # skip commented lines
test -z "$5" && continue # skip blank/bad writen lines
#client_ip rate_down ceil_down rate_up ceil_up #conf file format
ip[n]=$1; rate_down[n]=$2; ceil_down[n]=$3; rate_up[n]=$4; ceil_up[n]=$5;
# consecutive class/mark value assignation, begining from class_start
class_down[n]=$((class_start++))
class_prio_down[n]=$((class_start++))
class_dfl_down[n]=$((class_start++))
class_up[n]=$((class_start++))
class_prio_up[n]=$((class_start++))
class_dfl_up[n]=$((class_start++))
let _total_rate_down-=${rate_down[n]}; let _total_rate_up-=${rate_up[n]} #calc remaining rate
#give/grant $rate_granted kbits per "0 rate" class, stolen from total_rate
test ${rate_down[n]} == 0 && let _total_rate_down-=rate_granted && let total_ceil_down+=${ceil_down[n]}
test ${rate_up[n]} == 0 && let _total_rate_up-=rate_granted && let total_ceil_up+=${ceil_up[n]}
# some safe tests, boring, but newbie's trap
test $_total_rate_down -ge 0 || { echo "check rates conf, not enough download bandwidth" && exit 1; }
test $_total_rate_up -ge 0 || { echo "check rates conf, not enough upload bandwidth" && exit 1; }
test $total_rate_down -ge ${ceil_down[n]} || { echo "check rates conf, per host ceil can't be bigger than total_rate" && exit 1; }
test $total_rate_up -ge ${ceil_up[n]} || { echo "check rates conf, per host ceil can't be bigger than total_rate" && exit 1; }
let n++
done </dev/null
else
rm -f "${htb_dir}/"* 2>/dev/null
echo "R2Q=$r2q" > "${htb_dir}/${iface_down}"
echo "R2Q=$r2q" > "${htb_dir}/${iface_up}"
fi
;;
parent) cat >"${htb_dir}/${iface}-${parent}${parent:+:}${class}.${ip}" <<-EOF
RATE=${rate}kbit
CEIL=${ceil}kbit
BURST=${burst}k
EOF
;;
leaf) if [[ $prio -eq 1 ]] ; then ext="prio"; else ext="dfl"; fi
cat >"${htb_dir}/${iface}-${parent}:${class}.${ip}.${ext}" <<-EOF
RATE=${rate}kbit
CEIL=${ceil}kbit
BURST=${burst}k
PRIO=$prio
LEAF=sfq
MARK=$class
EOF
;;
esac
}

function do_tc () {
local mode=$1 ip=${2/\//_} rate=$3 ceil=$4 burst=$5 class=$6 parent=${7##*:} iface=$8 prio=$9
local quantum=$((rate*1024/8/r2q/dev/null
iptables -t mangle -D OUTPUT -o ${iface_down} -j htb-gen.down 2>/dev/null
iptables -t mangle -D POSTROUTING -o ${iface_up} -j htb-gen.up 2>/dev/null
iptables -t mangle -D FORWARD -o ${iface_up} -j htb-gen.up 2>/dev/null
while read line ;do
test -z "${line##:htb-gen*}" || continue # filter htb-gen chains only
chain=(${line/:/})
iptables -t mangle -F $chain
iptables -t mangle -X $chain
done <<-EOF
$(iptables-save)
EOF
#hack to echo an iptables-restore file, but i can steel write
#normal/readable iptables rules
iptables () {
case "$3" in
-A) shift 2
echo "$@"
;;
-N) echo ":${4} - [0:0]"
;;
esac
}
iptables-restore -n <<-EOF
*mangle
$(_do_iptables)
COMMIT
EOF
fi
}

case "$1" in
tc_all|tc_only|tc_stdout)
load_conf
test "$1" == "tc_stdout" && tc () { echo tc "$@"; }
test "$1" == "tc_all" && do_iptables
do_conf "tc"
;;
htbinit_all|htbinit_only)
load_conf
test "$1" == "htbinit_all" && do_iptables
do_conf "htbinit"
;;
iptables|iptables_only)
load_conf
do_iptables
;;
iptables_stdout)
load_conf
do_iptables "stdout"
;;
loadvars) load_conf
;;
*) cat <<-EOF
Usage:
$0 tc_all #execs tc rules & firewall rules
$0 tc_only #execs tc rules only (no firewall)
$0 tc_stdout #print tc rules to stdout
$0 htbinit_all #generates htb-init config files & load firewall rules
$0 htbinit_only #generates htb-init config files only (no firewall)
$0 iptables #execs firewall rules only (call it from your firewall script)
$0 iptables_stdout #print firewall rules to stdout (put them wherever you want)
$0 loadvars #for outside scripting & automation, see README for details
EOF
;;
esac

Estube jugando un poco sin resultados, termine dejando la original con las modificaciones que explican en el COMO y sigo sin Segmentacion del Upstream.

---------------------------------------------------------------------------------------
P/D: al agregar un nuevo puerto a segmentar me devuelve el sieguiente error:

# htb-gen tc_all
iptables-restore v1.2.11: too many ports specified
Error occurred at line: 13
Try `iptables-restore -h' or 'iptables-restore --help' for more information.

Al principio agrege el puerto 3128, ya que por ahi pasa mi proxy y cuando quise agregar el puerto 8080 como se ve mas abajo me tira el error anterior.
prio_ports=20,21,22,25,80,110,143,443,465,993,995,1863,1864,3389,3128,8080

Segun entienedo hay demasiados puertos asignados, tiene un limite de puertos? o como se puede segmentar TODO el trafico, es decir por todos los puertos existentes.?
Gracias!
---------------------------------
GNU/Linux|The Future Technology|

---------------------------------
GNU/Linux|The Future Technology|

Sigo sin poder segmentar upstream

Imagen de micronic

Hola! Despues de mucho tiempo de verme alejado de todo esto vuelvo a la carga.. :) , Esta ves con Centos 5.3 + Shorewall + SQUID 2.6 STABLE21 + Control MAC con IP NAIG + DHCP + DNS-CACHE.Hasta el momento todo perfecto, funcionando de 10. el problema ahora es HTB-GEN que segmente a la perfeccion el Downstream pero no el Upstream, intente varias configuraciones, tocando el archivo /usr/bin/htb-gen y no pasa nada, baje el SQUID y quite las reglas de shorewall para el proxy y tampoco pasa nada.
Alguien tubo este problema y lo soluciono? :?
Que usan ustedes para limitar el ancho de banda?

Un Abrazo suerte!

---------------------------------
GNU/Linux|The Future Technology|

Yo he probado el htb-gen y

Imagen de nino1511

Yo he probado el htb-gen y también tengo problemas con la subida, no la límita, ciertos puertos como el 20, 21 si pero el 80 sale con toda la velocidad que tengo, si alguien nos puede dar una solución seria estupendo, aclaro con la bajada no hay problema.

Saludos

Vamos Ecuador, si se puede

Aun no logre solucionar el problema

Imagen de micronic

Hola!
Amigos por mas que busco no encuentro la manera de solucionar el problema, me segmenta perfectamente la bajada pero no la subida, segui los pasos del COMO perfectamente. Alguien lo soluciono? sigo buscando y toqueteando si encuentro una solucion la posteo, gracias.

---------------------------------
GNU/Linux|The Future Technology|