Bandbreitenbegrenzung

F

flammenflitzer

Routinier
Hallo
Ich habe ein USB Kabelmodem (eth0) mit 1000 kbits/sek. Wieter habe ich im Rechner 2 Netzwerkkarten (eth1 und eth2). Mittels Shorewall habe ich ICS eingerichtet. (Also alle 3 Rechner sind gleichzeitig im Internet.) Jetzt haben sich mein Sohn und meine Frau beschwert, weil mitunter 90% des Durchsatz von meinem Rechner genutzt werden.
Gibt es eine Möglichkeit, die Bandbreite so zu begrenzen, daß für meine IP 50% und 50% für die anderen beiden LAN-Rechner reserviert werden.
 
flammenflitzer schrieb:
Gibt es eine Möglichkeit, die Bandbreite so zu begrenzen, daß für meine IP 50% und 50% für die anderen beiden LAN-Rechner reserviert werden.

"Taffic Shaping" heisst das Stichwort. Und "tc" das dazugehoerige Programm, zu finden im Paket iproute2. Ein weiteres Stichwort ist "htb" - history token bucket, eins der Verfahren, nach dem der Verkehr "geshapet" wird. Inzwischen gibt es auch Beispiele fuer dessen Verwendung im Netz zu finden.
Prinzipiell ist es moeglich, allein mit tc-Mitteln (u32 identifier) den Verkehr zu regeln, allerdings wird es mit Markierungen, die die Firewall anbringt (via iptables), gleich viel einfacher, da dank ipt_helper viele Moeglichkeiten geboten werden, ein Paket zu klassifizieren.
Ob shorewall derartiges unterstuetzt, weiss ich leider nicht.

-khs, begeisterter shaper ;)
 
shorewall-traffic_shaping
Das läuft doch, wenn ich das richtig verstanden habe, darauf hinaus, daß ich den Netzwerkkarten bzw. dem Verkehr zuerst Prioritäten und dann Bandbreite zuweise?
Code:
Example 1. 

All packets arriving on eth1 should be marked with 1. All packets arriving on eth2 and eth3 should be marked with 2. All packets originating on the firewall itself should be marked with 3.

#MARK   SOURCE    DESTINATION    PROTO   PORT(S)   SOURCE PORT(S)   USER/GROUP    TEST
1       eth1      0.0.0.0/0      all
2       eth2      0.0.0.0/0      all
2       eth3      0.0.0.0/0      all
3       fw        0.0.0.0/0      all

Example 2. 

All GRE (protocol 47) packets not originating on the firewall and destined for 155.186.235.151 should be marked with 12.

#MARK   SOURCE    DESTINATION     PROTO   PORT(S)    SOURCE PORT(S)     USER/GROUP    TEST
12      0.0.0.0/0 155.182.235.151 47

Example 3. 

All SSH packets originating in 192.168.1.0/24 and destined for 155.186.235.151 should be marked with 22.

#MARK   SOURCE         DESTINATION     PROTOCOL   PORT(S)       SOURCE PORT(S)   USER/GROUP    TEST
22      192.168.1.0/24 155.182.235.151 tcp        22

My Current Setup

I am currently using the HTB version of The Wonder Shaper (I just copied wshaper.htb to /etc/shorewall/tcstart and modified it as shown in the Wondershaper README). WonderShaper DOES NOT USE THE /etc/shorewall/tcrules file.
My Old Setup

I have also run with the following set of hand-crafted rules in my /etc/shorewall/tcstart file.

run_tc qdisc add dev eth0 root handle 1: htb default 30

run_tc class add dev eth0 parent 1: classid 1:1 htb rate 384kbit burst 15k
echo “   Added Top Level Class -- rate 384kbit”

run_tc class add dev eth0 parent 1:1 classid 1:10 htb rate 140kbit ceil 384kbit burst 15k prio 1
run_tc class add dev eth0 parent 1:1 classid 1:20 htb rate 224kbit ceil 384kbit burst 15k prio 0
run_tc class add dev eth0 parent 1:1 classid 1:30 htb rate 20kbit  ceil 384kbit burst 15k quantum 1500 prio 1
echo “   Added Second Level Classes -- rates 140kbit, 224kbit, 20kbit”

run_tc qdisc add dev eth0 parent 1:10 pfifo limit 5
run_tc qdisc add dev eth0 parent 1:20 pfifo limit 10
run_tc qdisc add dev eth0 parent 1:30 pfifo limit 5
echo “   Enabled PFIFO on Second Level Classes”

run_tc filter add dev eth0 protocol ip parent 1:0 prio 1 handle 1 fw classid 1:10
run_tc filter add dev eth0 protocol ip parent 1:0 prio 0 handle 2 fw classid 1:20
run_tc filter add dev eth0 protocol ip parent 1:0 prio 1 handle 3 fw classid 1:30
echo “   Defined fwmark filters”

My tcrules file that went with this tcstart file is shown in Example 1 above. When I was using these rules:

   1.

      I wanted to allow up to 140kbits/second for traffic outbound from my DMZ (eth1 -- note that the ceiling is set to 384kbit so outbound DMZ traffic can use all available bandwidth if there is no traffic from the local systems or from my laptop or firewall).
   2.

      My laptop (which at that time connected via eth3) and local systems (eth2) could use up to 224kbits/second.
   3.

      My firewall could use up to 20kbits/second.
 
Ich weiß nicht, ob es hilft aber hier mal mein Script um Apache auf ne gewisse Bandbreite zu beschränken (Achtung, direkt aus der Krypt-a):
Code:
#!/bin/bash

if [ "$*" = "-d" ]; then
    tc qdisc del dev eth0 root
    iptables -t mangle -F OUTPUT
    exit
fi

iptables -t mangle -A OUTPUT -m owner --cmd-owner httpd -j MARK --set-mark 4
iptables -t mangle -A OUTPUT -m owner --cmd-owner !httpd -j MARK --set-mark 3

tc qdisc add dev eth0 root handle 10: htb default 1 r2q 1

tc class add dev eth0 parent 10:0 classid 10:1 htb rate 128kbit ceil 128kbit burst 6k cburst 6k quantum 1500 prio 0
tc class add dev eth0 parent 10:0 classid 10:2 htb rate 45kbit ceil 50kbit burst 6k cburst 6k quantum 12187 prio 8

tc filter add dev eth0 parent 10:0 protocol ip prio 0 handle 3 fw flowid 10:1
tc filter add dev eth0 parent 10:0 protocol ip prio 8 handle 4 fw flowid 10:2

tc qdisc add dev eth0 parent 10:1 sfq perturb 16 quantum 1500
tc qdisc add dev eth0 parent 10:2 sfq perturb 16 quantum 12187

Hier auch noch zwei Tutorials
http://www.prout.be/qos/QoS-connection-tuning-HOWTO.html#toc4
http://gentoo-wiki.com/HOWTO_Packet_Shaping
 
Zuletzt bearbeitet:

Ähnliche Themen

Bandbreitenbegrenzung mit shorewall

Zurück
Oben