Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[QoS] No consigo hacerlo tirar.
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Spanish
View previous topic :: View next topic  
Author Message
opotonil
l33t
l33t


Joined: 17 Jun 2005
Posts: 801
Location: 127.0.0.1

PostPosted: Mon Apr 23, 2007 12:01 pm    Post subject: [QoS] No consigo hacerlo tirar. Reply with quote

Hola,

estoy intentando poner QoS en mi PC y me estoy volviendo loco. Os pon go una parte significativa del script que estoy usando:
Code:

IPTABLES=/sbin/iptables
TC=/sbin/tc
IFACE_ETHERNET="eth1"
IFACE_WIRELESS="eth2"

ETHERNET_MAX="100mbit"
ETHERNET_RATE="12800kbit"
WIRELESS_MAX="54mbit"
WIRELESS_RATE="6912kbit"
WAN_MAX="4mbit"
WAN_RATE="512kbit"

LAN_PRIORITY_0="0"
...

WAN_PRIORITY_0="4"
...

 Interface ethernet
$TC qdisc add dev $IFACE_ETHERNET root handle 1:0 htb
# Interface wireless
$TC qdisc add dev $IFACE_WIRELESS root handle 2:0 htb

# Interface ethernet
$TC class add dev $IFACE_ETHERNET parent 1:0 classid 1:1 $ETHERNET_MAX ceil $ETHERNET_MAX
#Interface wireless
$TC class add dev $IFACE_WIRELESS parent 2:0 classid 2:1 $WIRELESS_MAX ceil $WIRELESS_MAX

# Interface ethernet on LAN
$TC class add dev $IFACE_ETHERNET parent 1:1 classid 1:10 htb rate $ETHERNET_RATE ceil $ETHERNET_MAX prio 0
...
# Interface ethernet on WAN
$TC class add dev $IFACE_ETHERNET parent 1:1 classid 1:14 htb rate $WAN_RATE ceil $WAN_MAX prio 0
...
# Interface wireless on LAN
$TC class add dev $IFACE_WIRELESS parent 2:1 classid 2:10 htb rate $WIRELESS_RATE ceil $WIRELESS_MAX prio 0
...
# Interface wireless on WAN
$TC class add dev $IFACE_WIRELESS parent 2:1 classid 2:14 htb rate $WAN_RATE ceil $WAN_MAX prio 0

# Interface ethernet on LAN
$TC qdisc add dev $IFACE_ETHERNET parent 1:10 handle 1:100 sfq perturb 10 quantum 1500
...
# Interface ethernet on WAN
$TC qdisc add dev $IFACE_ETHERNET parent 1:14 handle 1:104 sfq perturb 10 quantum 1500
...
# Interface wireless on LAN
$TC qdisc add dev $IFACE_WIRELESS parent 2:10 handle 2:100 sfq perturb 10 quantum 1500
...
# Interface wireless on WAN
$TC qdisc add dev $IFACE_WIRELESS parent 2:14 handle 2:104 sfq perturb 10 quantum 1500

# Interface ethernet on LAN
$TC filter add dev $IFACE_ETHERNET parent 1:0 protocol ip prio 0 handle $LAN_PRIORITY_0 fw classid 1:10
...
# Interface ethernet on WAN
$TC filter add dev $IFACE_ETHERNET parent 1:0 protocol ip prio 0 handle $WAN_PRIORITY_0 fw classid 1:14
...
# Interface wireless on LAN
$TC filter add dev $IFACE_WIRELESS parent 2:0 protocol ip prio 0 handle $LAN_PRIORITY_0 fw classid 2:10
...
# Interface wireless on WAN
$TC filter add dev $IFACE_WIRELESS parent 2:0 protocol ip prio 0 handle $WAN_PRIORITY_0 fw classid 2:14


# Setting default rule to drop
$IPTABLES -P FORWARD DROP
$IPTABLES -P INPUT   DROP
$IPTABLES -P OUTPUT  DROP


# Creating states chain
$IPTABLES -N allow-connection
$IPTABLES -F allow-connection
$IPTABLES -A allow-connection -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A allow-connection -j DROP


# Creating icmp chain
$IPTABLES -N allow-icmp
$IPTABLES -F allow-icmp
$IPTABLES -N allow-icmp -t mangle
$IPTABLES -F allow-icmp -t mangle
$IPTABLES -A allow-icmp -m state --state NEW -p icmp --icmp-type time-exceeded -j ACCEPT
$IPTABLES -A allow-icmp -m state --state NEW -p icmp --icmp-type time-exceeded -t mangle -m addrtype --dst-type LOCAL -j MARK --set-mark $LAN_PRIORITY_0
$IPTABLES -A allow-icmp -m state --state NEW -p icmp --icmp-type time-exceeded -t mangle -m addrtype --dst-type ! LOCAL -j MARK --set-mark $WAN_PRIORITY_0
#$IPTABLES -A allow-icmp -m state --state NEW -p icmp --icmp-type time-exceeded -j RETURN
$IPTABLES -A allow-icmp -m state --state NEW -p icmp --icmp-type destination-unreachable -j ACCEPT
$IPTABLES -A allow-icmp -m state --state NEW -p icmp --icmp-type destination-unreachable -t mangle -m addrtype --dst-type LOCAL -j MARK --set-mark $LAN_PRIORITY_0
$IPTABLES -A allow-icmp -m state --state NEW -p icmp --icmp-type destination-unreachable -t mangle -m addrtype --dst-type ! LOCAL -j MARK --set-mark $WAN_PRIORITY_0
#$IPTABLES -A allow-icmp -m state --state NEW -p icmp --icmp-type destination-unreachable -j RETURN
$IPTABLES -A allow-icmp -p icmp -j LOG --log-prefix "Bad ICMP traffic: "
$IPTABLES -A allow-icmp -p icmp -j DROP

# Applying chains to FORWARD"
$IPTABLES -A FORWARD -m state --state INVALID -j DROP
$IPTABLES -A FORWARD -p icmp -j allow-icmp
$IPTABLES -A FORWARD -p icmp -j allow-icmp -t mangle

# Applying chains to INPUT
$IPTABLES -A INPUT -m state --state INVALID -j DROP
$IPTABLES -A INPUT -p icmp -j allow-icmp

# Applying chains to OUTPUT"
$IPTABLES -A OUTPUT -m state --state INVALID -j DROP
$IPTABLES -A OUTPUT -p icmp -j allow-icmp
$IPTABLES -A OUTPUT -p icmp -j allow-icmp -t mangle


Los errores que me da al ejecutar el script son:
Quote:

RTNETLINK answers: File exists
RTNETLINK answers: File exists
Error: Qdisc "100mbit" is classless.
Error: Qdisc "54mbit" is classless.
RTNETLINK answers: File exists
...
RTNETLINK answers: Invalid argument
We have an error talking to the kernel
RTNETLINK answers: Invalid argument
We have an error talking to the kernel

todos ellos en la parte de QoS osea en los TC (TC=/sbin/tc), el error "RTNETLINK answers: File exists" pense que era porque ya existian asi que intente borrarlas con "tc qdisc del dev eth1 root" pero sigue dando el mismo error. Parte en la que no termino de entender para que son las lineas:
Code:

$TC qdisc add dev $IFACE_ETHERNET parent 1:10 handle 1:100 sfq perturb 10 quantum 1500

las demas, si no me equivoco son para crear las colas dandolas una prioridad y ver la marca de los paquetes para mandarlos a la cola adecuada.

En la parte de IPTABLES tengo alguna duda con la tabla mangle, que la verdad no la habia usado nunca, principalmente si necesito descomentar las lineas de RETURN que por lo que he leido si se usa en una subcadena lo devuelve a la cadena principal y si no pertenece a una subcadena aplica la regla por defecto. Pero la verdad que con eso me quedo igual... no termino de entender a que es una cadena y que es una subcadena en este caso.
Y por otro lado ¿esta bien el orden? o primero tendria que poner la marca y despues aceptar el paquete (al reves de como esta: 1º "... -t mangle -j MARK --set-mark" 2º "... -j ACCEPT")

Muchas gracias y salu2.
Back to top
View user's profile Send private message
gringo
Advocate
Advocate


Joined: 27 Apr 2003
Posts: 3793

PostPosted: Mon Apr 23, 2007 1:38 pm    Post subject: Reply with quote

igual es una pregunta estúpida pero tienes todo bien en el kernel y/o cargados los módulos ?

saluetes
_________________
Error: Failing not supported by current locale
Back to top
View user's profile Send private message
opotonil
l33t
l33t


Joined: 17 Jun 2005
Posts: 801
Location: 127.0.0.1

PostPosted: Mon Apr 23, 2007 3:07 pm    Post subject: Reply with quote

Pues no el kernel estaba bien, el problema era:
Code:

LAN_PRIORITY_0="0"

por lo visto no se puede marcar un paquete con "0", el resto de fallos eran errores tontos de sintaxis.

Bueno, fallos ya no da ahora me queda probarlo a ver si realmente funciona y en terarme de que es el "perturb" y el "quantum".

Gracias y salu2.

PD: Lo descubrire segun apague, pero ¿tengo que ejecutar el script cada vez que inicie? o ¿puedo guardar las colas con algun comando de iproute2 como con "iptables save"?

------- EDITADO ---------

Pues parece que funciona, pero que no resuelve mi principal problema que es que como tenga enchufado el mldonkey en el servidor no hay manera de conectar a el mediante ssh, para solucionar esto ¿tendria que usar IMQ?
Back to top
View user's profile Send private message
kalcetoh
Guru
Guru


Joined: 05 Jun 2005
Posts: 304

PostPosted: Mon Apr 23, 2007 6:43 pm    Post subject: Reply with quote

Menudo pifostio de comandos iptables y tc.
Para estos temas yo siempre he usado shorewall, que simplifica la vida bastante, y tiene la opción de configurar un traffic shaper de manera igualmente sencilla. Tienes bastante documentación en la página oficial.

Siento no poder ayudarte porque no piloto de los comandos iptables ni de los de tc, siempre he usado shorewall.
_________________
Hazmereir, un menéame de humor: Hazmereir
Back to top
View user's profile Send private message
opotonil
l33t
l33t


Joined: 17 Jun 2005
Posts: 801
Location: 127.0.0.1

PostPosted: Sat Apr 28, 2007 5:58 pm    Post subject: Reply with quote

kalcetoh, si llego a saber antes del shorewall seguramente lo hubiera usado, pero ahora que ya casi lo tengo y despues de lo que me a costado ya queria terminarlo.

Lo unico a ver si alguien sabe de alguna forma de cargar las colas (tc) en cada inicio o si la unica manera es creandome yo mismo un script.

Muchas gracias y salu2.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Spanish All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum