Názor k článku HTB - FAQ od Thor - pomoci tohoto to resim ja #!/bin/sh # **************************** Definice parametru...

  • Článek je starý, nové názory již nelze přidávat.
  • 9. 11. 2004 13:35

    Thor (neregistrovaný)

    pomoci tohoto to resim ja

    #!/bin/sh

    # **************************** Definice parametru ****************************
    TC=/sbin/tc
    IPTABLES=/usr/sbin/iptables

    INET_IFACE=eth0
    LAN_IFACE=eth1

    INET_SPEED_UPLOAD=256Kbit
    INET_SPEED_DOWNLOAD=256Kbit

    GARANCE1=32Kbit
    GARANCE2=64Kbit
    GARANCE3=128Kbit
    GARANCE4=256Kbit

    MAXIMUM1=64Kbit
    MAXIMUM2=128Kbit
    MAXIMUM3=256Kbit
    MAXIMUM4=512Kbit

    BURST=64k

    USER_01=192.168.1.55 #Uzivatel 1
    USER_02=192.168.1.62 #Uzivatel 2
    # **************************** Definice parametru ****************************

    #
    ############################### DOWNLOAD ############################
    #
    # Smazani vsech qdiscu na LAN interfacu

    $TC qdisc del dev $LAN_IFACE root >/dev/null

    # Pridani ROOT tridy na LAN interface

    $TC qdisc add dev $LAN_IFACE root handle 1:0 htb default 20

    #Nastaveni rychlosti tridy dle rychlosti pripojeno do internetu

    $TC class add dev $LAN_IFACE parent 1:0 classid 1:1 htb rate $INET_SPEED_DOWNLOAD burst $BURST

    #Nastaveni rychlosti trid na LAN rozhrani

    $TC class add dev $LAN_IFACE parent 1:1 classid 1:11 htb rate $GARANCE1 ceil $MAXIMUM2 burst $BURST #Klient 1
    $TC class add dev $LAN_IFACE parent 1:1 classid 1:12 htb rate $GARANCE1 ceil $MAXIMUM2 burst $BURST #Klient 2

    # ******************** Markovani paketu **************************************

    # Oznaceni paketu dle cilove IP adresy

    $IPTABLES -t mangle -A POSTROUTING -o $LAN_IFACE -d $USER_01 -j MARK --set-mark 1
    $IPTABLES -t mangle -A POSTROUTING -o $LAN_IFACE -d $USER_02 -j MARK --set-mark 2

    # Trizeni paketu do pridelenych trid

    $TC filter add dev $LAN_IFACE parent 1:0 protocol ip handle 1 fw flowid 1:11
    $TC filter add dev $LAN_IFACE parent 1:0 protocol ip handle 2 fw flowid 1:12

    #
    ############################### UPLOAD ############################
    #

    # Smazani vsech qdiscu na INET interfacu

    $TC qdisc del dev $INET_IFACE root >/dev/null

    # Pridani ROOT tridy na LAN interface

    $TC qdisc add dev $INET_IFACE root handle 1:0 htb default 20

    #Nastaveni rychlosti tridy dle rychlosti pripojeno do internetu

    $TC class add dev $INET_IFACE parent 1:0 classid 1:1 htb rate $INET_SPEED_UPLOAD burst $BURST

    #Nastaveni rychlosti trid na INET rozhrani

    $TC class add dev $INET_IFACE parent 1:1 classid 1:11 htb rate $GARANCE1 ceil $MAXIMUM1 burst $BURST #Klient 1
    $TC class add dev $INET_IFACE parent 1:1 classid 1:12 htb rate $GARANCE1 ceil $MAXIMUM3 burst $BURST #Klient 2



    #******************** Markovani paketu **************************************

    # Oznaceni paketu dle cilove IP adresy

    $IPTABLES -t mangle -A PREROUTING -i $LAN_IFACE -s $USER_01 -j MARK --set-mark 31
    $IPTABLES -t mangle -A PREROUTING -i $LAN_IFACE -s $USER_02 -j MARK --set-mark 32

    # Trizeni paketu do pridelenych trid

    $TC filter add dev $INET_IFACE parent 1:0 protocol ip handle 31 fw flowid 1:11
    $TC filter add dev $INET_IFACE parent 1:0 protocol ip handle 32 fw flowid 1:12