#!/bin/sh # # ip_qos # # UG QoS implementation # # Copyright (C)2009-2011, Universidad Galileo # Otto Solares ############### # definitions # ############### # Import definitions . /etc/network/ip_defs /etc/network/ip_qos_lan eth0 stop /etc/network/ip_qos_lan eth1 stop /etc/network/ip_qos_lan eth2 stop /etc/network/ip_qos_lan eth3 stop /etc/network/ip_qos_lan eth4 stop /etc/network/ip_qos_lan eth5 stop /etc/network/ip_qos_lan eth6 stop /etc/network/ip_qos_lan eth7 stop /etc/network/ip_qos_lan eth8 stop if [ "$1" = "stop" ]; then exit fi ####### # QoS # ####### # LAN networks ${TC} qdisc add dev eth0 root handle 1: prio bands 2 priomap 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 # simple small packets (<128) ${TC} filter add dev eth0 parent 1: protocol ip prio 1 u32 \ match u8 0x05 0x0f at 0 \ match u16 0x0000 0xff80 at 2 \ flowid 1:1 # services ${TC} filter add dev eth0 parent 1: protocol ip prio 1 u32 match ip protocol 6 0xff match ip dst 10.0.0.13 match ip dport 24 0xffff flowid 1:1 ${TC} filter add dev eth0 parent 1: protocol ip prio 1 u32 match ip protocol 17 0xff match ip dst 10.0.0.6 flowid 1:1 /etc/network/ip_qos_lan eth1 30000 /etc/network/ip_qos_lan eth2 30000 /etc/network/ip_qos_lan eth3 30000 /etc/network/ip_qos_lan eth6 30000 # WAN networks # claro main ${TC} qdisc add dev eth4 root handle 1: prio bands 3 priomap 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 #${TC} qdisc add dev eth4 parent 1:2 handle 20: red limit 5000000 min 208333 max 625000 avpkt 1000 burst 347 probability 0.02 bandwidth 25000 ecn ${TC} qdisc add dev eth4 parent 1:3 handle 13: sfb hash-type source limit 100 target 10 max 15 penalty_rate 60 ${TC} qdisc add dev eth4 parent 13: handle 131: sfq perturb 10 # simple small packets (<128) ${TC} filter add dev eth4 parent 1: protocol ip prio 1 u32 \ match u8 0x05 0x0f at 0 \ match u16 0x0000 0xff80 at 2 \ flowid 1:1 # services ${TC} filter add dev eth4 parent 1: protocol ip prio 1 u32 match ip protocol 6 0xff match ip sport 22 0xffff flowid 1:1 ${TC} filter add dev eth4 parent 1: protocol ip prio 1 u32 match ip protocol 6 0xff match ip dport 22 0xffff flowid 1:1 ${TC} filter add dev eth4 parent 1: protocol ip prio 1 u32 match ip protocol 17 0xff match ip src 200.9.255.13 flowid 1:1 ${TC} filter add dev eth4 parent 1: protocol ip prio 1 u32 match ip protocol 6 0xff match ip src 200.9.255.13 match ip sport 24 0xffff flowid 1:1 ${TC} filter add dev eth4 parent 1: protocol ip prio 1 u32 match ip protocol 17 0xff match ip src 200.9.255.6 flowid 1:1 ${TC} filter add dev eth4 parent 1: protocol ip prio 1 u32 match ip protocol 17 0xff match ip src 200.9.255.69 flowid 1:1 ${TC} filter add dev eth4 parent 1: protocol ip prio 1 u32 match ip protocol 6 0xff match ip src 200.9.255.69 match ip sport 554 0xffff flowid 1:1 ${TC} filter add dev eth4 parent 1: protocol ip prio 1 u32 match ip protocol 6 0xff match ip src 200.9.255.69 match ip sport 1755 0xffff flowid 1:1 ${TC} filter add dev eth4 parent 1: protocol ip prio 1 u32 match ip protocol 6 0xff match ip src 200.9.255.152 match ip sport 3389 0xffff flowid 1:1 # google-claro cache netblock ${TC} filter add dev eth4 parent 1: protocol ip prio 2 u32 match ip dst 200.6.228.0/24 flowid 1:2 # google netblock ${TC} filter add dev eth4 parent 1: protocol ip prio 2 u32 match ip dst 216.239.32.0/19 flowid 1:2 ${TC} filter add dev eth4 parent 1: protocol ip prio 2 u32 match ip dst 64.233.160.0/19 flowid 1:2 ${TC} filter add dev eth4 parent 1: protocol ip prio 2 u32 match ip dst 66.249.80.0/20 flowid 1:2 ${TC} filter add dev eth4 parent 1: protocol ip prio 2 u32 match ip dst 72.14.192.0/18 flowid 1:2 ${TC} filter add dev eth4 parent 1: protocol ip prio 2 u32 match ip dst 209.85.128.0/17 flowid 1:2 ${TC} filter add dev eth4 parent 1: protocol ip prio 2 u32 match ip dst 66.102.0.0/20 flowid 1:2 ${TC} filter add dev eth4 parent 1: protocol ip prio 2 u32 match ip dst 74.125.0.0/16 flowid 1:2 ${TC} filter add dev eth4 parent 1: protocol ip prio 2 u32 match ip dst 64.18.0.0/20 flowid 1:2 ${TC} filter add dev eth4 parent 1: protocol ip prio 2 u32 match ip dst 207.126.144.0/20 flowid 1:2 ${TC} filter add dev eth4 parent 1: protocol ip prio 2 u32 match ip dst 173.194.0.0/16 flowid 1:2 ${TC} filter add dev eth4 parent 1: protocol ip prio 2 u32 match ip dst 216.73.93.70/31 flowid 1:2 ${TC} filter add dev eth4 parent 1: protocol ip prio 2 u32 match ip dst 216.73.93.72/31 flowid 1:2 # other physical links ${TC} qdisc add dev eth5 root pfifo ${TC} qdisc add dev eth7 root pfifo ${TC} qdisc add dev eth8 root pfifo exit 0