Nie jesteś zalogowany.
Jeśli nie posiadasz konta, zarejestruj je już teraz! Pozwoli Ci ono w pełni korzystać z naszego serwisu. Spamerom dziękujemy!

Ogłoszenie

Prosimy o pomoc dla małej Julki — przekaż 1% podatku na Fundacji Dzieciom zdazyć z Pomocą.
Więcej informacji na dug.net.pl/pomagamy/.

#1  2012-01-23 22:29:16

  oli - Zbanowany

oli
Zbanowany
Zarejestrowany: 2012-01-08

Problemy z IMQ

Już mi ręce opadają. Nie mogę poradzić sobie z prostym skryptem HTB. Zawsze coś pod górkę.
Mój przykładowy, testowy skrypt.

Kod:

### BEGIN INIT INFO
# Provides:          firewall
# Required-Start:    $syslog
# Required-Stop:     $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: hardisk firewall daemon
# Description:
#
### END INIT INFO

# wlaczenie w kernelu forwardowania
echo 1 > /proc/sys/net/ipv4/ip_forward
# czyszczenie starych regul
iptables -F
iptables -X
iptables -t nat -X
iptables -t nat -F
# ustawienie polityki dzialania
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
# zezwolenie nna laczenie sie z naszym zewnetrznym ip po ssh

iptables -A INPUT -i lo -j ACCEPT
iptables -A FORWARD -o lo -j ACCEPT

iptables -A INPUT -s 0/0 -d 192.168.88.110 -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -s 0/0 -d  192.168.88.110 -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -s 0/0 -d  192.168.88.110 -p udp --dport 22 -j ACCEPT
iptables -A OUTPUT -s 0/0 -d  192.168.88.110 -p udp --dport 22 -j ACCEPT
# polaczenia nawiazane
iptables -A INPUT -j ACCEPT -m state --state ESTABLISHED,RELATED
iptables -A FORWARD -j ACCEPT -m state --state ESTABLISHED,RELATED
iptables -A OUTPUT -j ACCEPT -m state --state ESTABLISHED,RELATED
# udostepniaie internetu w sieci lokalnej
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j MASQUERADE
iptables -A FORWARD -s 192.168.1.0/24 -j ACCEPT
#HTB
/sbin/modprobe imq
iptables -t mangle -A PREROUTING -i eth1 -j IMQ --todev 0
iptables -t mangle -A POSTROUTING -o eth1 -j IMQ --todev 1
#kolejka glowna
tc qdisc add dev imq0 root handle 1:0 htb
tc class add dev imq0 parent 1:0 classid 1:1 htb rate 7400kbit ceil 7400kbit quantum 1500

# kolejka dla serwera
tc class add dev imq0 parent 1:1 classid 1:2 htb rate 500kbit ceil 3000kbit quantum 1500
tc qdisc add dev imq0 parent 1:2 sfq perturb 10 quantum 1500b
tc filter add dev imq0 parent 1:0 pref 2 protocol ip u32 match ip dst 192.168.88.110 flowid 1:2

# kolejki dla uzytkownikow
tc class add dev imq0 parent 1:1 classid 1:3 htb rate 500kbit ceil 3000kbit quantum 1500
tc qdisc add dev imq0 parent 1:3 sfq perturb 10 quantum 1500b
tc filter add dev imq0 parent 1:0 pref 3 protocol ip u32 match ip dst 192.168.1.7 flowid 1:3
ip link set imq0 up

#UPLOAD
#kolejka glowna
tc qdisc add dev imq1 root handle 1:0 htb
tc class add dev imq1 parent 1:0 classid 1:1 htb rate 2000kbit ceil 5000kbit quantum 1500
# kolejka dla serwera
tc class add dev imq1 parent 1:1 classid 1:2 htb rate 100kbit ceil 2000kbit quantum 1500
tc qdisc add dev imq1 parent 1:2 sfq perturb 10 quantum 1500b
tc filter add dev imq1 parent 1:0 pref 2 protocol ip u32 match ip src 192.168.88.110 flowid 1:2

# kolejki dla uzytkownikow
tc class add dev imq1 parent 1:1 classid 1:3 htb rate 100kbit ceil 2000kbit quantum 1500
tc qdisc add dev imq1 parent 1:3 sfq perturb 10 quantum 1500b
tc filter add dev imq1 parent 1:0 pref 3 protocol ip u32 match ip src 192.168.1.7 flowid 1:3
ip link set imq1 up

Po odpaleniu wywala to:

Kod:

root@debian:/etc/init.d# ./firewall
iptables v1.4.8: unknown option `--todev'
Try `iptables -h' or 'iptables --help' for more information.
iptables v1.4.8: unknown option `--todev'
Try `iptables -h' or 'iptables --help' for more information.
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists

root@debian:~#

Czy trzeba załatać  iptables dla IMQ???
Kompilując nowe jajko załatałem tylko to > patch-imqmq-3.1.diff

A tak poza tym co powinno się nałożyć na kernel i na iptables by wszystko działało jak należy.

Ostatnio edytowany przez oli (2012-01-23 22:49:53)

Offline

 

#2  2012-01-23 23:18:41

  Jacekalex - Podobno człowiek...;)

Jacekalex
Podobno człowiek...;)
Skąd: /dev/random
Zarejestrowany: 2008-01-07

Re: Problemy z IMQ

Iptables też musi mieć łatkę IMQ, żeby działał cel IMQ --todev.

Jak skompilujesz iptables z łatką, to potem sprawdź, czy cel IMQ działa, np tak:

root  #  iptables -j IMQ  --help | grep -iA2 IMQ
IMQ target options:
  --todev <N>        enqueue to imq<N>, defaults to 0

U mnie jak widać, iptables wie, o co chodzi z IMQ ;).

To by było na tyle
;-)

Ostatnio edytowany przez Jacekalex (2012-01-23 23:21:31)


W demokracji każdy naród ma taką władzę, na jaką zasługuje ;)
Si vis pacem  para bellum  ;)       |       Pozdrawiam :)

Offline

 

#3  2012-01-23 23:35:01

  oli - Zbanowany

oli
Zbanowany
Zarejestrowany: 2012-01-08

Re: Problemy z IMQ

Ok, usunąłem stare iptables. Załatałem i zainstalowałem.
Już rozmawia z --todev ale ....

Kod:

root@debian:/etc/init.d# ./firewall
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists
RTNETLINK answers: File exists

root@debian:~/iptables-1.4.12.2#

Poza tym:

Kod:

root@debian:~/iptables-1.4.12.2# iptables -j IMQ  --help | grep -iA2 IMQ
IMQ target options:
  --todev <N>           enqueue to imq<N>, defaults to 0
root@debian:~/iptables-1.4.12.2#

Hmmm, chyba nie czyści mi kolejek na nowo po odpaleniu skryptu.

Ostatnio edytowany przez oli (2012-01-23 23:45:13)

Offline

 

Stopka forum

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson
Możesz wyłączyć AdBlock — tu nie ma reklam ;-)