QOS com Iptables
Publicado por Júlio César Mauro 24/10/2005
[ Hits: 24.477 ]
Este script tem a funcao de limitar a banda do usuario em 1/4 da banda
especificada na variavel RATEUP. Caso a banda total nao esteja sendo utilizado,
o usuario que estiver utilizando o sistema, pode utilizar a banda total
#!/bin/sh #chkconfig: 2345 11 89 # Autor: Julio Cesar Mauro <julio.mauro<at>gmail.com # Data: 23/10/2004 # Versao: 1.0 # Descricao: Este script tem a funcao de limitar a banda do usuario em 1/4 da banda # especificada na variavel RATEUP. Caso a banda total nao esteja sendo utilizado, # o usuario que estiver utilizando o sistema, pode utilizar a banda total. . /etc/rc.d/init.d/functions . /etc/sysconfig/network [ ${NETWORKING} = "no" ] && exit 0 DEV=eth0 RATEUP=256 RATEDN=700 IPT="/sbin/iptables" TC="/sbin/tc" HOSTS="172.16.24.0/24" case "$1" in start) ################################################################################################ # Add HTB root qdisc $TC qdisc add dev $DEV root handle 1: htb default 26 2> /dev/null > /dev/null $IPT -A FORWARD -t mangle -p udp --sport 1024:49151 -j TOS --set-tos Maximize-Throughput $IPT -A FORWARD -t mangle -p udp --dport 1024:49151 -j TOS --set-tos Maximize-Throughput $IPT -A FORWARD -t mangle -p tcp --sport 1:65535 -j TOS --set-tos Minimize-Delay $IPT -A FORWARD -t mangle -p tcp --dport 1:65535 -j TOS --set-tos Minimize-Delay # Adiciona root qdisc $TC qdisc add dev $DEV root handle 1: htb default 50 2> /dev/null > /dev/null $TC class add dev $DEV parent 1: classid 1:1 htb rate ${RATEUP}kbit 2> /dev/null > /dev/null # Classes # $TC class add dev $DEV parent 1:1 classid 1:20 htb rate $[$RATEUP/4]kbit ceil ${RATEUP}kbit prio 0 2> /dev/null > /dev/null # Sqf # $TC qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10 2> /dev/null > /dev/null # Filtros # $TC filter add dev $DEV parent 1:0 prio 0 protocol ip handle 20 fw flowid 1:20 2> /dev/null > /dev/null $TC filter add dev $DEV parent 1:0 protocol ip prio 0 u32 match ip dst $HOSTS classid 1:20 2> /dev/null > /dev/null # Marca pacotes # $IPT -A FORWARD -t mangle $IPT -A PREROUTING -t mangle -d 172.16.24.0/24 -j MARK --set-mark 1 $IPT -t nat -I POSTROUTING -s 172.16.24.0/24 -d 0/0 -o $DEV -j MASQUERADE $IPT -A FORWARD -t mangle -p tcp --dport 1:65535 -j MARK --set-mark 23 $IPT -A FORWARD -t mangle -p tcp --sport 1:65535 -j MARK --set-mark 23 $IPT -A FORWARD -t mangle -p icmp -j MARK --set-mark 20 $IPT -A FORWARD -t mangle -p udp -j MARK --set-mark 21 $IPT -A FORWARD -t mangle -m mark --mark 0 -j MARK --set-mark 26 echo "Adicionado Regras de QoS:" ; ;; ################################################################################################# stop) $TC qdisc del dev $DEV root 2> /dev/null > /dev/null $IPT -D FORWARD -t mangle -p udp --sport 1024:49151 -j TOS --set-tos Maximize-Throughput $IPT -D FORWARD -t mangle -p udp --dport 1024:49151 -j TOS --set-tos Maximize-Throughput $IPT -D FORWARD -t mangle -p tcp --sport 1:65535 -j TOS --set-tos Minimize-Delay $IPT -D FORWARD -t mangle -p tcp --dport 1:65535 -j TOS --set-tos Minimize-Delay $IPT -D FORWARD -t mangle $IPT -D FORWARD -t mangle -p tcp --dport 1:65535 -j MARK --set-mark 23 $IPT -D FORWARD -t mangle -p tcp --sport 1:65535 -j MARK --set-mark 23 $IPT -D FORWARD -t mangle -p icmp -j MARK --set-mark 20 $IPT -D FORWARD -t mangle -p udp -j MARK --set-mark 21 $IPT -D FORWARD -t mangle -m mark --mark 0 -j MARK --set-mark 26 echo "Removendo Regras de QoS:" ; ;; ################################################################################################# status) echo "[qdisc]" $TC -s qdisc show dev $DEV echo "[class]" $TC -s class show dev $DEV echo "[filter]" $TC -s filter show dev $DEV exit ;; *) echo "Usage: qos {start|stop|restart|status}" exit 1 esac # EOF # ##################################################################################################
Administrar squid com autenticação, simples e objetivo.
Administração servidor WEB com Dialog
Usando netstat para verificar conexões e portas
Enviar mensagem ao usuário trabalhando com as opções do php.ini
Meu Fork do Plugin de Integração do CVS para o KDevelop
Compartilhando a tela do Computador no Celular via Deskreen
Como Configurar um Túnel SSH Reverso para Acessar Sua Máquina Local a Partir de uma Máquina Remota
Configuração para desligamento automatizado de Computadores em um Ambiente Comercial
Compartilhamento de Rede com samba em modo Público/Anônimo de forma simples, rápido e fácil
Cups: Mapear/listar todas as impressoras de outro Servidor CUPS de forma rápida e fácil
Criando uma VPC na AWS via CLI
Tem como instalar o gerenciador AMD Adrenalin no Ubuntu 24.04? (15)
Tenho dois Link's ( IP VÁLIDOS ), estou tentando fazer o failover... (0)
Pendrive não formata de jeito nenhum (4)