Control de trafico de red (QOS): dslqosqueue.

Por Paco Aldarias Raya

Impreso: 10 de octubre 2004

Email: pacolinux arroba inicia punto es

Web: http://aldarias.es/pacodebian

Con Linux Debian. En Valencia (España)

Este documento es de libre reproducción siempre que se cite su fuente.

Realizado con: LATEX

Índice General


1 Introducción

Vamos a ver como dar prioridad en la conexión a internet según el tipo de servicio. Esto nos va a permitir poder tener ciertos servicios una calidad de conexión adecuada.

El control se realiza sobre el tráfico saliente. Vamos a dar prioridades del 20 al 26. El 20 es la máxima prioridad y la 26 es la menor prioridad.

Puertos Prioridad Comentario
0:1024 23 Default for low port traffic
20 26 ftp-data port, low prio
5190 23 aol instant messenger
icmp 20 ICMP (ping) - high prio, impress friends
udp 21 DNS name resolution (small packets)
ssh 22 secure shell
http 25 Local web server
64 21 small packets (probably just ACKs)
3389 23 windows remote computer connection
6346 26 Default for low port traffic

2 Requisitos

3 Barjarse el archivo: dsl_qos_queue-0.7.tar.gz - v0.7

Localizado en:
http://www.sonicspike.net/software/

Descomprimierlo:

tar xzpf dsl_qos_queue-0.7.tar.gz

Una vez descomprimido copiamos esto:

cp dsl_qos_queue/dsl_qos_queue /usr/bin/

4 Crear este script

Comprobar que la tarjeta de red q sale a internet es eth1, sino cambiarla por eth0 si fuera esta.

cat /etc/init.d/dslqos

#!/bin/bash
# add MYSHAPER-OUT chain to the mangle table in iptables - this sets up the table we'll use
#  to filter and mark packets.

 

DEV=eth1
CMD="/usr/local/bin/dsl_qos_queue -d -i $DEV -r 15900"

 

function cleanup(){
# Reset everything to a known state (cleared)
echo iptables -t mangle -D POSTROUTING -o $DEV -j MYSHAPER-OUT
iptables -t mangle -D POSTROUTING -o $DEV -j MYSHAPER-OUT  2> /dev/null > /dev/null

 

echo iptables -t mangle -F MYSHAPER-OUT
iptables -t mangle -F MYSHAPER-OUT  2> /dev/null > /dev/null

 

echo iptables -t mangle -X MYSHAPER-OUT
iptables -t mangle -X MYSHAPER-OUT  2> /dev/null > /dev/null
}

 

function install(){
echo iptables -t mangle -N MYSHAPER-OUT
iptables -t mangle -N MYSHAPER-OUT

 

iptables -t mangle -I POSTROUTING -o $DEV -j MYSHAPER-OUT
echo iptables -t mangle -I POSTROUTING -o $DEV -j MYSHAPER-OUT

 

echo -n "Set priorities..."
# add fwmark entries to classify different types of traffic - Set fwmark from 20-26 according to
#  desired class. 20 is highest prio.
iptables -t mangle -A MYSHAPER-OUT -p tcp --sport 0:1024 -j MARK --set-mark 23 # Default for low port traffic 
iptables -t mangle -A MYSHAPER-OUT -p tcp --dport 0:1024 -j MARK --set-mark 23 # "" 
iptables -t mangle -A MYSHAPER-OUT -p tcp --dport 20 -j MARK --set-mark 26  # ftp-data port, low prio
iptables -t mangle -A MYSHAPER-OUT -p tcp --dport 5190 -j MARK --set-mark 23  # aol instant messenger
iptables -t mangle -A MYSHAPER-OUT -p icmp -j MARK --set-mark 20  # ICMP (ping) - high prio, impress friends
iptables -t mangle -A MYSHAPER-OUT -p udp -j MARK --set-mark 21  # DNS name resolution (small packets)
iptables -t mangle -A MYSHAPER-OUT -p tcp --dport ssh -j MARK --set-mark 22  # secure shell
iptables -t mangle -A MYSHAPER-OUT -p tcp --sport ssh -j MARK --set-mark 22  # secure shell
#iptables -t mangle -A MYSHAPER-OUT -p tcp --dport telnet -j MARK --set-mark 22 # telnet (ew...)
#iptables -t mangle -A MYSHAPER-OUT -p tcp --sport telnet -j MARK --set-mark 22 # telnet (ew...)
#iptables -t mangle -A MYSHAPER-OUT -p ipv6-crypt -j MARK --set-mark 24  # IPSec - we dont know what the payload is though...
iptables -t mangle -A MYSHAPER-OUT -p tcp --sport http -j MARK --set-mark 25  # Local web server
iptables -t mangle -A MYSHAPER-OUT -p tcp -m length --length :64 -j MARK --set-mark 21 # small packets (probably just ACKs)
iptables -t mangle -A MYSHAPER-OUT -p tcp --sport 3389 -j MARK --set-mark 23  # windows remote computer connection
iptables -t mangle -A MYSHAPER-OUT -m mark --mark 0 -j MARK --set-mark 26  # redundant- mark any unmarked packets as 26 (low pri
iptables -t mangle -A MYSHAPER-OUT -p tcp --sport 6346 -j MARK --set-mark 26  # Default for low port traffic 
echo " done."

 

}

 

case "$1" in
  start)
  $CMD
  cleanup
  install
  ;;
  stop|stop)
  killall dsl_qos_queue
  cleanup
  ;;
  status)
  iptables -t mangle -L
  cat /proc/net/ip_queue
  ;;
  restart)
  killall dsl_qos_queue
  sleep 1
  $CMD
  cleanup
  install
  ;;
  *)
  echo "Usage: $0 {start|stop|restart|status}"
  exit 1
esac

 

exit 0

5 Arrancarlo

6 Comprobaciones

7 Bibliografia

  1. 3.09 QoS (Quality of Service / Calidad de Servicio) por BocaDePez
    http://www.bandaancha.st/documentos.php?docid=62

  2. Qos para equilibra r tráfico por IP y limitar tráfico P 2P
    http://guadawireless.net/modules.php?op=modload&name=News&file=article&sid=255

  3. Enrutamiento avanzado y control de tráfico en Linux
    http://www.gulic.org/comos/LARTC/lartc.html#AEN588


Índice de Materias

dslqosqueue
1
iptables
1
mangle
1

Sobre este documento...

Control de trafico de red (QOS): dslqosqueue.

This document was generated using the LaTeX2HTML translator Version 2002-2-1 (1.70)

Copyright © 1993, 1994, 1995, 1996, Nikos Drakos, Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999, Ross Moore, Mathematics Department, Macquarie University, Sydney.

The command line arguments were:
latex2html dslqosqueue -split 0 -local_icons 1 -show_section_numbers -no_auto_link -no_navigation

The translation was initiated by on 2004-10-10


2004-10-10