wiec tak:
to jest konfiguracja na 3xlan (eth0 eth1 eth2) neo na usb
/usr/src/rchtb/ready/fwmarks.htb
IPT=/usr/sbin/iptables
stop()
{
$IPT -F -t mangle
$IPT -X -t mangle
}
start()
{
$IPT -t mangle -A OUTPUT -j MARK --set-mark 1
$IPT -t mangle -A PREROUTING -s 10.10.10.10 -j MARK --set-mark 2
$IPT -t mangle -A PREROUTING -s 10.10.10.11 -j MARK --set-mark 3
$IPT -t mangle -A PREROUTING -s 10.10.10.2 -j MARK --set-mark 4
$IPT -t mangle -A PREROUTING -s 10.10.10.3 -j MARK --set-mark 5
$IPT -t mangle -A PREROUTING -s 10.10.10.9 -j MARK --set-mark 6
$IPT -t mangle -A PREROUTING -s 192.168.0.2 -j MARK --set-mark 7
$IPT -t mangle -A PREROUTING -s 192.168.1.4 -j MARK --set-mark 8
}
case $1 in
'start')
start
;;
'stop')
stop
;;
*)
echo -e "\nUżycie: fwmarks.htb start|stop"
esac
/usr/src/rchtb/ready/rc.htb
#!/bin/bash
# rc.htb 0.3.3-stable, (C)PriSM 2oo3, GNU GPL
# <http://www.rc.htb.prv.pl/>
# Poprawki Zciech 0.1
# wygenerowano: 01/05/05 20:14:04
VER=0.3.3-stable
stop()
{
/sbin/rchtb_tc qdisc del root dev ppp0 2> /dev/null
/sbin/rchtb_tc qdisc del root dev eth0 2> /dev/null
/sbin/rchtb_tc qdisc del root dev eth1 2> /dev/null
}
start()
{
stop # dla bezpieczeństwa
# INTERFEJS ETH0 (ruch przychodzący)
/sbin/rchtb_tc qdisc add dev eth0 root handle 1:0 htb default 3 r2q 1
/sbin/rchtb_tc qdisc add dev eth1 root handle 1:0 htb default 3 r2q 1
# Główna klasa dla eth0
/sbin/rchtb_tc class add dev eth0 parent 1:0 classid 1:1 htb rate 90000kbit ceil 90000kbit
/sbin/rchtb_tc class add dev eth1 parent 1:0 classid 1:1 htb rate 90000kbit ceil 90000kbit
# Podział na pasmo dla łącza internetowego i resztę
/sbin/rchtb_tc class add dev eth0 parent 1:1 classid 1:2 htb rate 126kbit ceil 126kbit
/sbin/rchtb_tc class add dev eth0 parent 1:1 classid 1:3 htb rate 89874kbit ceil 89874kbit prio 9
/sbin/rchtb_tc qdisc add dev eth0 parent 1:3 sfq perturb 10
/sbin/rchtb_tc class add dev eth1 parent 1:1 classid 1:2 htb rate 126kbit ceil 126kbit
/sbin/rchtb_tc class add dev eth1 parent 1:1 classid 1:3 htb rate 89874kbit ceil 89874kbit prio 9
/sbin/rchtb_tc qdisc add dev eth1 parent 1:3 sfq perturb 10
# pasmo priorytetowe dla ICMP, TOS 0x10 (min. delay) oraz wybranego portu 22
/sbin/rchtb_tc class add dev eth0 parent 1:2 classid 1:20 htb rate 21kbit ceil 126kbit prio 1 quantum 1500
/sbin/rchtb_tc qdisc add dev eth0 parent 1:20 sfq perturb 10
/sbin/rchtb_tc filter add dev eth0 protocol ip prio 3 parent 1:0 u32 match ip sport 22 0xffff flowid 1:20
/sbin/rchtb_tc filter add dev eth0 protocol ip prio 2 parent 1:0 u32 match ip tos 0x10 0xff flowid 1:20
/sbin/rchtb_tc filter add dev eth0 protocol ip prio 2 parent 1:0 u32 match ip protocol 1 0xff flowid 1:20
# Komputer_szymon 192.168.0.2
/sbin/rchtb_tc class add dev eth1 parent 1:2 classid 1:26 htb rate 21kbit ceil 100kbit prio 2 quantum 1500
/sbin/rchtb_tc qdisc add dev eth1 parent 1:26 sfq perturb 10
/sbin/rchtb_tc filter add dev eth1 protocol ip prio 5 parent 1:0 u32 match ip dst 192.168.0.2 flowid 1:26
# Komputer_tata 192.168.1.4
/sbin/rchtb_tc class add dev eth1 parent 1:2 classid 1:27 htb rate 21kbit ceil 100kbit prio 2 quantum 1500
/sbin/rchtb_tc qdisc add dev eth1 parent 1:27 sfq perturb 10
/sbin/rchtb_tc filter add dev eth1 protocol ip prio 5 parent 1:0 u32 match ip dst 192.168.1.4 flowid 1:27
# Komputer_10
/sbin/rchtb_tc class add dev eth0 parent 1:2 classid 1:21 htb rate 21kbit ceil 126kbit prio 2 quantum 1500
/sbin/rchtb_tc qdisc add dev eth0 parent 1:21 sfq perturb 10
/sbin/rchtb_tc filter add dev eth0 protocol ip prio 5 parent 1:0 u32 match ip dst 10.10.10.10 flowid 1:21
# Komputer_11
/sbin/rchtb_tc class add dev eth0 parent 1:2 classid 1:22 htb rate 21kbit ceil 126kbit prio 2 quantum 1500
/sbin/rchtb_tc qdisc add dev eth0 parent 1:22 sfq perturb 10
/sbin/rchtb_tc filter add dev eth0 protocol ip prio 5 parent 1:0 u32 match ip dst 10.10.10.11 flowid 1:22
# Komputer_2
/sbin/rchtb_tc class add dev eth0 parent 1:2 classid 1:23 htb rate 21kbit ceil 100kbit prio 2 quantum 1500
/sbin/rchtb_tc qdisc add dev eth0 parent 1:23 sfq perturb 10
/sbin/rchtb_tc filter add dev eth0 protocol ip prio 5 parent 1:0 u32 match ip dst 10.10.10.2 flowid 1:23
# Komputer_3
/sbin/rchtb_tc class add dev eth0 parent 1:2 classid 1:24 htb rate 21kbit ceil 100kbit prio 2 quantum 1500
/sbin/rchtb_tc qdisc add dev eth0 parent 1:24 sfq perturb 10
/sbin/rchtb_tc filter add dev eth0 protocol ip prio 5 parent 1:0 u32 match ip dst 10.10.10.3 flowid 1:24
# Komputer_9
/sbin/rchtb_tc class add dev eth0 parent 1:2 classid 1:25 htb rate 21kbit ceil 100kbit prio 2 quantum 1500
/sbin/rchtb_tc qdisc add dev eth0 parent 1:25 sfq perturb 10
/sbin/rchtb_tc filter add dev eth0 protocol ip prio 5 parent 1:0 u32 match ip dst 10.10.10.9 flowid 1:25
# transfer serwer->LAN
/sbin/rchtb_tc filter add dev eth0 protocol ip prio 1 parent 1:0 handle 1 fw flowid 1:3
/sbin/rchtb_tc filter add dev eth1 protocol ip prio 1 parent 1:0 handle 1 fw flowid 1:3
# INTERFEJS PPP0 (ruch wychodzący)
/sbin/rchtb_tc qdisc add dev ppp0 root handle 2:0 htb default 11 r2q 1
# główna klasa
/sbin/rchtb_tc class add dev ppp0 parent 2:0 classid 2:1 htb rate 52kbit ceil 52kbit
# klasa priorytetowa ACK
/sbin/rchtb_tc class add dev ppp0 parent 2:1 classid 2:10 htb rate 6kbit ceil 40kbit prio 1 quantum 1500
/sbin/rchtb_tc qdisc add dev ppp0 parent 2:10 sfq perturb 10
/sbin/rchtb_tc filter add dev ppp0 parent 2:0 protocol ip prio 2 u32 match ip protocol 6 0xff \
match u8 0x05 0x0f at 0 match u16 0x0000 0xffc0 at 1 match u8 0x10 0xff at 33 flowid 2:10 # ACK
# klasa priorytetowa TOS 0x10 oraz ICMP
/sbin/rchtb_tc class add dev ppp0 parent 2:1 classid 2:9 htb rate 4kbit ceil 40kbit prio 2 quantum 1500
/sbin/rchtb_tc qdisc add dev ppp0 parent 2:9 sfq perturb 10
/sbin/rchtb_tc filter add dev ppp0 parent 2:0 protocol ip prio 1 u32 match ip tos 0x10 0xff flowid 2:9 # TOS 0x10
/sbin/rchtb_tc filter add dev ppp0 parent 2:0 protocol ip prio 2 u32 match ip dport 22 0xffff flowid 2:9 # port 22
/sbin/rchtb_tc filter add dev ppp0 parent 2:0 protocol ip prio 1 u32 match ip protocol 1 0xff flowid 2:9 # ICMP
# Komputer_10
/sbin/rchtb_tc class add dev ppp0 parent 2:1 classid 2:12 htb rate 9kbit ceil 47kbit prio 2 quantum 1500
/sbin/rchtb_tc qdisc add dev ppp0 parent 2:12 sfq perturb 10
/sbin/rchtb_tc filter add dev ppp0 parent 2:0 protocol ip prio 5 handle 2 fw flowid 2:12
# Komputer_11
/sbin/rchtb_tc class add dev ppp0 parent 2:1 classid 2:13 htb rate 9kbit ceil 30kbit prio 2 quantum 1500
/sbin/rchtb_tc qdisc add dev ppp0 parent 2:13 sfq perturb 10
/sbin/rchtb_tc filter add dev ppp0 parent 2:0 protocol ip prio 5 handle 3 fw flowid 2:13
# Komputer_2
/sbin/rchtb_tc class add dev ppp0 parent 2:1 classid 2:14 htb rate 9kbit ceil 30kbit prio 2 quantum 1500
/sbin/rchtb_tc qdisc add dev ppp0 parent 2:14 sfq perturb 10
/sbin/rchtb_tc filter add dev ppp0 parent 2:0 protocol ip prio 5 handle 4 fw flowid 2:14
# Komputer_3
/sbin/rchtb_tc class add dev ppp0 parent 2:1 classid 2:15 htb rate 9kbit ceil 30kbit prio 2 quantum 1500
/sbin/rchtb_tc qdisc add dev ppp0 parent 2:15 sfq perturb 10
/sbin/rchtb_tc filter add dev ppp0 parent 2:0 protocol ip prio 5 handle 5 fw flowid 2:15
# Komputer_9
/sbin/rchtb_tc class add dev ppp0 parent 2:1 classid 2:16 htb rate 9kbit ceil 30kbit prio 2 quantum 1500
/sbin/rchtb_tc qdisc add dev ppp0 parent 2:16 sfq perturb 10
/sbin/rchtb_tc filter add dev ppp0 parent 2:0 protocol ip prio 5 handle 6 fw flowid 2:16
# Komputer_szymon
/sbin/rchtb_tc class add dev ppp0 parent 2:1 classid 2:17 htb rate 9kbit ceil 30kbit prio 2 quantum 1500
/sbin/rchtb_tc qdisc add dev ppp0 parent 2:17 sfq perturb 10
/sbin/rchtb_tc filter add dev ppp0 parent 2:0 protocol ip prio 5 handle 7 fw flowid 2:17
# Komputer_tata
/sbin/rchtb_tc class add dev ppp0 parent 2:1 classid 2:18 htb rate 9kbit ceil 30kbit prio 2 quantum 1500
/sbin/rchtb_tc qdisc add dev ppp0 parent 2:18 sfq perturb 10
/sbin/rchtb_tc filter add dev ppp0 parent 2:0 protocol ip prio 5 handle 8 fw flowid 2:18
/sbin/rchtb_tc filter add dev ppp0 parent 2:0 protocol ip prio 9 u32 match ip dst 0/0 flowid 2:11
# ruch serwerowy (pasmo dla go?ci z zewn?trz)
# /sbin/rchtb_tc class add dev ppp0 parent 2:3 classid 2:11 htb rate 30kbit ceil 35kbit prio 2 quantum 1500
# /sbin/rchtb_tc qdisc add dev ppp0 parent 2:11 sfq perturb 10
# /sbin/rchtb_tc filter add dev ppp0 parent 2:0 protocol ip prio 3 handle 1 fw flowid 2:11
}
echo "rc.htb 0.3.3-stable, (C)PriSM 2oo3. Na licencji GNU GPL."
echo "Strona projektu: http://www.rc.htb.prv.pl/"
case "$1" in
'start')
echo -n "Uruchamianie kolejkowania..."
start
echo " wykonano."
;;
'stop')
echo -n "Zatrzymywanie kolejkowania..."
stop
echo " wykonano."
;;
'restart')
echo -n "Restartowanie kolejkowania: stop"
stop
echo -n " start"
start
echo " wykonano."
;;
'status')
echo "Klasy na interfejsie eth0"
echo "================================"
tc class show dev eth0 | grep root
tc class show dev eth0 | grep -v root | sort | nl
tc class show dev eth1 | grep root
tc class show dev eth1 | grep -v root | sort | nl
echo "Klasy na interfejsie ppp0"
echo "==================================="
tc class show dev ppp0 | grep root
tc class show dev ppp0 | grep -v root | sort | nl
;;
*)
echo -e "\nUżycie: rc.htb start|stop|restart|status"
;;
esac
chyba wszystko