Nowe posty

Autor Wątek: Podział pasma - sprawdzenie poprawności skryptu.  (Przeczytany 2184 razy)

sponsoriada

  • Gość
Podział pasma - sprawdzenie poprawności skryptu.
« dnia: 2011-07-14, 22:37:56 »
Witam. Mam tutaj napisany przeze mnie skrypt do zarządzania pasmem. Prosiłbym o zerknięcie na niego czy wszystko jest ok. Szczególną uwagę prosiłbym zwrócić na "prio". Nie wiedziałem czy trzeba go użyć przy tworzeniu klasy czy filtrach. Chciałbym aby ssh i wszystko co idzie z gier szło w prio 1 czyli jako najwyższy priorytet, czy sfq jest dobrze użyte, oraz podział pasma w sieci Lan.
eth0 - interfejs zew
eth1 - interfejs wew
#!/bin/sh

ifconfig eth0 down
ifconfig eth0 hw ether 00:17:9A:61:AC:62
dhclient eth0
ifconfig eth1 192.168.1.1 up

echo "1" > /proc/sys/net/ipv4/ip_forward

#Czyszczenie tablic
iptables -F -t nat
iptables -X -t nat
iptables -F -t filter
iptables -X -t filter

#Domyślna polityka działania
iptables -t filter -P INPUT ACCEPT
iptables -t filter -P FORWARD DROP
iptables -t filter -P OUTPUT ACCEPT

#Przekierowanie pakietów
iptables -t filter -A FORWARD -s 192.168.1.0/255.255.255.0 -d 0/0 -j ACCEPT
iptables -t filter -A FORWARD -s 0/0 -d 192.168.1.0/255.255.255.0 -j ACCEPT

#NAT
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j SNAT --to-source 212.180.172.206

#Przekierowania portów
#iptables -t nat -A PREROUTING -p tcp -i eth0 -s 0/0 --dport 1550 -j DNAT --to 192.168.1.2

#Przekierowania PS3
iptables -t nat -A PREROUTING -p tcp -i eth0 -s 0/0 --dport 443 -j DNAT --to 192.168.1.201
iptables -t nat -A PREROUTING -p tcp -i eth0 -s 0/0 --dport 5223 -j DNAT --to 192.168.1.201
iptables -t nat -A PREROUTING -p udp -i eth0 -s 0/0 --dport 3478 -j DNAT --to 192.168.1.201
iptables -t nat -A PREROUTING -p udp -i eth0 -s 0/0 --dport 3479 -j DNAT --to 192.168.1.201
iptables -t nat -A PREROUTING -p udp -i eth0 -s 0/0 --dport 3658 -j DNAT --to 192.168.1.201

######KSZTALTOWANIE RUCHU#####
#CZYSZCZENIE KOLEJEK
tc qdisc del root dev eth0
tc qdisc del root dev eth1

#TWORZENIE KLAS DLA INTERFEJSOW
tc qdisc add dev eth0 root handle 1:0 htb default 10
tc qdisc add dev eth1 root handle 2:0 htb default 10

#OGRANICZAMY PASMO
tc class add dev eth0 parent 1:0 classid 1:1 htb rate 1500kbit ceil 1500kbit
tc class add dev eth1 parent 2:0 classid 2:1 htb rate 100000 kbit ceil 100000kbit

#KLASY ETH0
tc class add dev eth0 parent 1:1 classid 1:10 htb rate 1000kbit ceil 1500kbit
tc class add dev eth0 parent 1:1 classid 1:20 htb rate 500kbit ceil 1500kbit
tc qdisc add dev eth0 parent 1:10 handle 10:0 sfq perturb 10
tc qdisc add dev eth0 parent 1:20 handle 20:0 sfq perturb 10
tc filter add dev eth0 protocol ip parent 1:1 prio 1 u32 match ip sport 22 0xffff flowid 1:10
tc filter add dev eth0 protocol ip parent 1:1 prio 1 u32 match ip dport 80 0xffff flowid 1:10
tc filter add dev eth0 protocol ip parent 1:1 prio 1 u32 match src 192.168.1.201/24 flowid 1:10
tc filter add dev eth0 protocol ip parent 1:1 prio 1 u32 match src 192.168.1.200/24 flowid 1:10
tc filter add dev eth0 protocol ip parent 1:1 prio 2 flowid 10:20


#KLASY ETH1
#NIEKLASYFIKOWANE
tc class add dev eth1 parent 2:1 classid 2:10 htb rate 5000kbit ceil 100000kbit
tc qdisc add dev eth1 parent 2:10 handle 10: sfq perturb 10
tc filter add dev eth1 protocol ip parent 2:1 prio 2 flowid 2:10

#192.168.1.1 SERWER
tc class add dev eth1 parent 2:1 classid 2:11 htb rate 30000kbit ceil 100000kbit
tc filter add dev eth1 protocol ip parent 2:1 u32 match src 192.168.1.1/24 flowid 2:11
tc qdisc add dev eth1 parent 2:11 handle 11: sfq perturb 10

#192.168.1.100 MOJA TOSHIBA
tc class add dev eth1 parent 2:1 classid 2:100 htb rate 20000kbit ceil 100000kbit
tc filter add dev eth1 protocol ip parent 2:1 u32 match src 192.168.1.100/24 flowid 2:100
tc qdisc add dev eth1 parent 2:100 handle 100: sfq perturb 10

#192.168.1.102 KH
tc class add dev eth1 parent 2:1 classid 2:102 htb rate 10000kbit ceil 100000kbit
tc filter add dev eth1 protocol ip parent 2:1 u32 match src 192.168.1.102/24 flowid 2:102
tc qdisc add dev eth1 parent 2:102 handle 102: sfq perturb 10

#192.168.1.104 JELONEK
tc class add dev eth1 parent 2:1 classid 2:104 htb rate 10000kbit ceil 100000kbit
tc filter add dev eth1 protocol ip parent 2:1 u32 match src 192.168.1.104/24 flowid 2:104
tc qdisc add dev eth1 parent 2:104 handle 104: sfq perturb 10

#192.168.1.200 VOIP
tc class add dev eth1 parent 2:1 classid 2:200 htb rate 10000kbit ceil 100000kbit
tc filter add dev eth1 protocol ip parent 2:1 u32 match src 192.168.1.200/24 flowid 2:200
tc qdisc add dev eth1 parent 2:200 handle 200: sfq perturb 10

#192.168.1.201 PS3
tc class add dev eth1 parent 2:1 classid 2:201 htb rate 10000kbit ceil 100000kbit
tc filter add dev eth1 protocol ip parent 2:1 u32 match src 192.168.1.201/24 flowid 2:201
tc qdisc add dev eth1 parent 2:201 handle 201: sfq perturb 10

hostname espons.pl
killall -9 dhcpd
dhcpd eth1