Freesco, NND, CDN, EOS

http://www.freesco.pl
Dzisiaj jest sobota, 27 kwietnia 2024, 16:53

Strefa czasowa UTC+2godz.




Nowy temat Odpowiedz w temacie  [ Posty: 1 ] 
Autor Wiadomość
Post: poniedziałek, 8 października 2007, 21:52 
Offline

Rejestracja: czwartek, 20 września 2007, 18:09
Posty: 1
Posiadał skrypt, który dzieli 3 łącza na usługi.
1. łącze defaultowe (DSL 4mb) przekazuje cały ruch nieoznaczony (wszystkie pakiety nieoznaczone trafiają do niego, p2p, ipp2p,...)
2. drugie łącze: Polpak z puli adresów zewnętrznych przydzielany jest adres zewnętrzny dla firmy oraz na róźne usługi, które potrzebują dobre pingi.
3. łacze trzecie (Dsl 4mb) na nim idą wszystkie port 80 (www) dla całej podsieci.
Problem jest taki, że skrypt zbyt mocno tnie p2p, programy p2p nie chcą wogóle się łaczyć (emule), BearShare ściąganie ma bardzo liche.
Jak by coś blokowało. Łacze trzecie, które jest przeznaczone dla www spisuję się dobrze, dzieli automatycznie ze względu na obciążenie.
Podczas testów skryptu napotkałem się z uwagami klientów, że podczas gier online (Lineage.II) napotykają się ciągłymi disconektami, podczas rozmów voip szumy i zakłucenia, skype to samo. Przekierowałem porty w/w na łącze Polpaka i nic się nie poprawiło.
Drugie pytanie jak skonfigurować, żeby więcej osób mogło otrzymać zewnętrzne ip (mam skonfigurowane jedno przekierowanie wewnętrznego ip na zewnętrzne z puli Polpaka)
Do tej pory używałem podziału 2 łącz przez rchtb skonfigurowanego przez zciecha, nowe łącze doszło i chciałbym je przeznaczyć dla p2p a tu klops. Z góry dziękuje za pomoc i sugestie dotyczące błedów.
Skrypt wygląda następująco:

#!/bin/sh

# SKRYPT DO PODZIALU 3 LACZ DSL NA USLUGI.
# W MOIM PRZYPADKU INSTALOWALEM NND 0.1 Z LIPCA (W WERSJI SCSI),
# PONIEWAZ WERSJA 0.2 NIE CHCIALA SIE URUCHOMIC NA MOIM KONTROLERZE SCSI ADAPTECA,
# DLATEGO SCIAGALEM DODATKOWO KERNEL OBSLUGUJACY 2 LACZA.
# WYKONAŁEM INSTRUKCJE: (JESLI MASZ ZAINSTALOWANA WERSJE NND 0.2, TO
# PRAWDOPODOBNIE NIE MUSISZ ICH WYKONYWAC,
# BO NND W WERSJI 0.2 MA JUZ OBSLUGE WIELU LACZY)
# wget http://devel-nnd.brb.pl/nnd/repo.test/k ... pkg.tar.gz
# pacman -U kernel24-scsi-2.4.32-8nnd.pkg.tar.gz
# wget http://devel-nnd.brb.pl/nnd/repo.test/i ... pkg.tar.gz
# pacman -U iptables-1.3.4-8nnd.pkg.tar.gz
# lilo -v
# reboot
# UWAGA! POCZATKOWA KONFIGURACJA SIECI Z JEDNYM DSL BYLA ROBIONA
# KONFIGURATOREM NNDCONF.NASTEPNIE W STANDARDOWYM PLIKU
# FIREWALLA /etc/iptables/firewall WSZEDZIE TAM GDZIE
# WYSTEPOWALO $EXTIF DODALEM DODATKOWE WIERSZE ZAMIENIAJAC
# WPIS $EXTIF NA $EXTIF2,BY FIREWALL UWZGLEDNIAL OBA INTERFEJSY Z DSL,
# ZMIENNA EXTIF2 DOPISALEM TAKZE W /etc/rc.conf (EXTIF2="eth2")
# UWAGA! ABY SKRYPT DZIAŁAŁ POPRAWNIE NALEŻY DODAĆ DO PLIKU
# /etc/iproute2/rt_tables WPIS: 250 www

echo "Uruchamiam podzial 3xDSL na uslugi"

IF0="eth1" # LAN
IF1="eth0" # POLPAK
IF2="eth2" # DSL1 www1
IF3="eth3" # DSL2 www2

IP0="192.168.0.1" #IP
IP1="195.205.**.226" # POLPAK
IP2="83.12.**.154" # DSL 1, Defaultowe
IP3="79.187.***.250" # DSL 2,

IP0_NET="255.255.255.0" # MASKA
IP1_NET="255.255.255.224"
IP2_NET="255.255.255.248"
IP3_NET="255.255.255.248"

IP0_BC="192.168.0.255" #BROADCAST
IP1_BC="195.205.**.255"
IP2_BC="83.12.**.159"
IP3_BC="79.187.***.255"

P1="195.205.**.225" #Bramka
P2="83.12.**.153" #Bramka
P3="79.187.***.249" #Bramka

P0_NET="192.168.0.0/24" #ADRES SIECI
P1_NET="195.205.**.224/27"
P2_NET="83.12.**.152/29"
P3_NET="79.187.***.248/29"

# interfejs zewnetrzne ip
IF_ZEW1="eth0" #zmienione na eth3 zeby przez dsl2

ifconfig $IF0 down
ifconfig $IF1 down
ifconfig $IF2 down
ifconfig $IF3 down
###ifconfig $IF4 down
#ifconfig $IF0:1 down #Marcin, ??, druga podsiec

# zewnetrzne ip i dopasowane lokalne ip
# tu trzeba zostawiac poprzedni nr,zeby mogl wykasowac poprzedni interfejs
IP_WEW1_NR_OLD="9"
ifconfig -a $IF_ZEW1:$IP_WEW1_NR_OLD down
# a tu wpisujemy juz nowy nr
IP_WEW1_NR="245"
IP_WEW1="192.168.0.245"
IP_ZEW1="195.205.**.247"
IP_ZEW1_NET="255.255.255.224"
IP_ZEW1_BC="195.205.**.255"
P_ZEW1="195.205.**.225"
#Zmienione dla dsla2
#IP_ZEW1="79.187.***.252"
#IP_ZEW1_NET="255.255.255.248"
#IP_ZEW1_BC="79.187.***.255"
#P_ZEW1="79.187.***.249"

#IP_WEW2_NR="246"
#IP_WEW2="192.168.0.246"
#IP_ZEW2="195.205.12.246"

/etc/iptables/firewall stop
/etc/iptables/firewall start

ifconfig $IF0 $IP0 netmask $IP0_NET broadcast $IP0_BC
ifconfig $IF1 $IP1 netmask $IP1_NET broadcast $IP1_BC
ifconfig $IF2 $IP2 netmask $IP2_NET broadcast $IP2_BC
ifconfig $IF3 $IP3 netmask $IP3_NET broadcast $IP3_BC
###ifconfig $IF4 $IP4 netmask $IP4_NET broadcast $IP4_BC
#ifconfig $IF0:1 192.168.2.1 up druga podsiec

# alias na zewnetrzne ip
#ip a a $IP_ZEW1 dev $IF_ZEW1
ifconfig -a $IF_ZEW1:$IP_WEW1_NR $IP_ZEW1 netmask $IP_ZEW1_NET broadcast $IP_ZEW1_BC
#ifconfig -a $IF_ZEW1:$IP_WEW2_NR $IP_ZEW2 netmask $IP_ZEW1_NET broadcast $IP_ZEW1_BC #Marcin, ?

#echo "1" > /proc/sys/net/ipv4/conf/rp_filter
echo "1" > /proc/sys/net/ipv4/conf/all/rp_filter
echo "0" > /proc/sys/net/ipv4/conf/eth0/rp_filter
echo "0" > /proc/sys/net/ipv4/conf/eth2/rp_filter
echo "0" > /proc/sys/net/ipv4/conf/eth3/rp_filter
###echo "0" > /proc/sys/net/ipv4/conf/eth4/rp_filter
echo "1" > /proc/sys/net/ipv4/conf/default/rp_filter

# ZMIEJSZENIE TIMEOUT-OW DLA ODPOWIEDNICH PAKIETOW DO GRANIC AKCEPTOWALNYCH
# PRZEZ NIEKTORE PROGRAMY (TROCHĘ ZMODYFIKOWANE W STOSUNKU DO DANYCH Z NND-WIKI)
echo 8192 > /proc/sys/net/ipv4/ip_conntrack_max
echo 8192 > /proc/sys/net/ipv4/netfilter/ip_conntrack_max
echo 1800 > /proc/sys/net/ipv4/tcp_keepalive_time
echo 30 > /proc/sys/net/ipv4/tcp_fin_timeout
echo 50 > /proc/sys/net/ipv4/netfilter/ip_conntrack_generic_timeout #600
echo 20 > /proc/sys/net/ipv4/netfilter/ip_conntrack_icmp_timeout #30
echo 15 > /proc/sys/net/ipv4/netfilter/ip_conntrack_tcp_timeout_close #10
echo 120 > /proc/sys/net/ipv4/netfilter/ip_conntrack_tcp_timeout_close_wait #60
echo 7200 > /proc/sys/net/ipv4/netfilter/ip_conntrack_tcp_timeout_established #172800
echo 120 > /proc/sys/net/ipv4/netfilter/ip_conntrack_tcp_timeout_fin_wait #120
echo 30 > /proc/sys/net/ipv4/netfilter/ip_conntrack_tcp_timeout_last_ack #30
echo 60 > /proc/sys/net/ipv4/netfilter/ip_conntrack_tcp_timeout_time_wait
echo 10 > /proc/sys/net/ipv4/netfilter/ip_conntrack_udp_timeout

ip route del default
ip route del table www1
ip route del table www2
###ip route del table www3
ip route del table ip_zew

#ip rule del prio 253 table default
#ip rule add prio 253 table default
#ip rule del prio 251 table www1
#ip rule add prio 251 table www1
#ip rule del prio 250 table www2
#ip rule add prio 250 table www2
#ip rule del prio 249 table www3
#ip rule add prio 249 table www3
#ip rule del prio 248 table ip_zew
#ip rule add prio 248 table ip_zew

# 1 - lacze p2p, 2 - lacze www1, 3 - lacze www2 4 - lacze www3
ip route add default via $P2 dev $IF2
ip route add $P1_NET src $IP1 dev $IF1 table www1
ip route add $P3_NET src $IP3 dev $IF3 table www2
###ip route add $P4_NET src $IP4 dev $IF4 table www3
ip route add default via $P1 dev $IF1 table www1
ip route add default via $P3 dev $IF3 table www2
###ip route add default via $P4 dev $IF4 table www3
ip route add $P0_NET src $IP0 dev $IF0 table www1
ip route add $P0_NET src $IP0 dev $IF0 table www2
###ip route add $P0_NET src $IP0 dev $IF0 table www3

# dodanie rutingu ip zewnetrznego
ip route add $IP_ZEW1_NET src $IP_ZEW1 dev $IF_ZEW1 table ip_zew
ip route add default via $P_ZEW1 dev $IF_ZEW1 table ip_zew
#ip route add $IP_ZEW1_NET src $IP_ZEW2 dev $IF_ZEW1 table ip_zew #Marcin
#ip route add default via $P_ZEW1 dev $IF_ZEW1 table ip_zew #Marcin, ??

ip rule del fwmark 0x700 table main
ip rule del fwmark 0x800 table www1
ip rule del fwmark 0x850 table www2
####ip rule del fwmark 0x900 table www3
ip rule del fwmark 0x650 table ip_zew
ip rule add fwmark 0x700 table main
ip rule add fwmark 0x850 table www2
ip rule add fwmark 0x800 table www1
####ip rule add fwmark 0x900 table www3
ip rule add fwmark 0x650 table ip_zew
ip route flush cache

# CZYSZCZENIE WPISOW W TABLICY MANGLE
iptables -F -t mangle
iptables -X -t mangle

# pozwolenie na forwarding wewnetrznego ip i dodanie rutowania zewnetrznego ip
iptables -A FORWARD -i $IF_ZEW1 -d $IP_WEW1 -j ACCEPT
iptables -t nat -A POSTROUTING -s $IP_WEW1 -o $IF_ZEW1 -j SNAT --to $IP_ZEW1
iptables -t nat -A PREROUTING -d $IP_ZEW1 -j DNAT --to $IP_WEW1
iptables -t mangle -A PREROUTING -s $IP_WEW1 -j MARK --set-mark 0x650
iptables -t mangle -A PREROUTING -d $IP_WEW1 -j MARK --set-mark 0x650

#iptables -A FORWARD -i $IF_ZEW1 -d $IP_WEW2 -j ACCEPT #Marcin, ?
#iptables -t nat -A POSTROUTING -s $IP_WEW2 -o $IF_ZEW1 -j SNAT --to $IP_ZEW2 #Marcin, ?
#iptables -t nat -A PREROUTING -d $IP_ZEW2 -j DNAT --to $IP_WEW2 #Marcin, ?
#iptables -t mangle -A PREROUTING -s $IP_WEW2 -j MARK --set-mark 0x650 #Marcin, ?
#iptables -t mangle -A PREROUTING -d $IP_WEW2 -j MARK --set-mark 0x650 #Marcin

# NAT
#iptables -t nat -A POSTROUTING -s $IP_WEW1 -o $IF_ZEW1 -j SNAT --to $IP_ZEW1 #Marcin, ??

iptables -t nat -A POSTROUTING -s $P0_NET -d! $P0_NET -o $IF1 -j SNAT --to $IP1
iptables -t nat -A POSTROUTING -s $P0_NET -d! $P0_NET -o $IF2 -j SNAT --to $IP2
iptables -t nat -A POSTROUTING -s $P0_NET -d! $P0_NET -o $IF3 -j SNAT --to $IP3
####iptables -t nat -A POSTROUTING -s $P0_NET -d! $P0_NET -o $IF4 -j SNAT --to $IP4

# BLOKADA PORTOW PRZECIW WIRUSOM
iptables -I FORWARD -p tcp --dport 135 -j DROP
iptables -I FORWARD -p udp --dport 135 -j DROP
iptables -I FORWARD -p tcp --dport 137:138 -j DROP
iptables -I FORWARD -p udp --dport 137:138 -j DROP
iptables -I FORWARD -p tcp --dport 445 -j DROP
iptables -I FORWARD -p udp --dport 445 -j DROP

# JESLI JAKIS PAKIET JEST JUZ OZNACZONY,TO WYCHODZI Z MANGLE DO NASTEPNEJ TABLICY
iptables -t mangle -A PREROUTING -m mark ! --mark 0x0 -j RETURN

# OGRANICZENIE ILOSCI AKTYWNYCH POLACZEN TCP
iptables -t mangle -A FORWARD -p tcp -m connlimit --connlimit-above 60 -j DROP

# PRZYWROCENIE WARTOSCI MARK DLA NAWIAZANYCH POLACZEN
iptables -t mangle -A PREROUTING -j CONNMARK --restore-mark

# JESLI SIE OKAZE,ZE JAKIES P2P NIE DZIALAJA NA PORTACH PREFEROWANYCH,
# TO ZOSTANA ZAZNACZONE I PRZEKAZANE NA LACZE DLA P2P
iptables -t mangle -A PREROUTING -p tcp -m ipp2p --ipp2p -j MARK --set-mark 0x700
# ZACHOWANIE DLA POTOMNYCH
iptables -t mangle -A PREROUTING -p tcp -m mark --mark 0x700 -j CONNMARK --save-mark

# JESLI JAKIS PAKIET JEST JUZ OZNACZONY,TO WYCHODZI Z MANGLE DO NASTEPNEJ TABLICY
iptables -t mangle -A PREROUTING -m mark ! --mark 0x0 -j RETURN

# PING
iptables -t mangle -A PREROUTING -p icmp -j MARK --set-mark 0x800
iptables -t mangle -A OUTPUT ! -d 194.204.159.1 -p icmp -j MARK --set-mark 0x800
#iptables -t mangle -A OUTPUT -p icmp -j MARK --set-mark 0x800 #BYLO
# DNS
iptables -t mangle -A PREROUTING -p tcp --dport 53 -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p udp --dport 53 -j MARK --set-mark 0x800
iptables -t mangle -A OUTPUT -p tcp --dport 53 -j MARK --set-mark 0x800
iptables -t mangle -A OUTPUT -p udp --dport 53 -j MARK --set-mark 0x800

# SSH
iptables -t mangle -A PREROUTING -p tcp --dport 22 -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p udp --dport 22 -j MARK --set-mark 0x800

# TELNET
iptables -t mangle -A PREROUTING -p tcp --dport 23 -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p udp --dport 23 -j MARK --set-mark 0x800

# WWW
for((ip=2;ip<=224;ip++))
do
iptables -t mangle -A PREROUTING -p tcp --dport 80 -s 192.168.0.$ip -j MARK --set-mark 0x850
iptables -t mangle -A PREROUTING -p tcp --dport 80 -d 192.168.0.$ip -j MARK --set-mark 0x850
iptables -t mangle -A PREROUTING -p udp --dport 80 -s 192.168.0.$ip -j MARK --set-mark 0x850
iptables -t mangle -A PREROUTING -p udp --dport 80 -d 192.168.0.$ip -j MARK --set-mark 0x850

done

for((ip=225;ip<=255;ip++))
do
iptables -t mangle -A PREROUTING -p tcp --dport 80 -s 192.168.0.$ip -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p tcp --dport 80 -d 192.168.0.$ip -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p udp --dport 80 -s 192.168.0.$ip -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p udp --dport 80 -d 192.168.0.$ip -j MARK --set-mark 0x800

done

# WWW SZYFROWANE I TLEN
iptables -t mangle -A PREROUTING -p tcp --dport 443 -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p udp --dport 443 -j MARK --set-mark 0x800

# GADU GADU
iptables -t mangle -A PREROUTING -p tcp --dport 8074 -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p udp --dport 8074 -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p tcp --dport 1550 -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p udp --dport 1550 -j MARK --set-mark 0x800

# POCZTA
iptables -t mangle -A PREROUTING -p tcp --dport 25 -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p tcp --dport 110 -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p tcp --dport 993 -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p tcp --dport 995 -j MARK --set-mark 0x800

# FTP
iptables -t mangle -A PREROUTING -p tcp --dport 20 -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p tcp --dport 21 -j MARK --set-mark 0x800

# USENET
iptables -t mangle -A PREROUTING -p tcp --dport 119 -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p udp --dport 119 -j MARK --set-mark 0x800

# IRC
iptables -t mangle -A PREROUTING -p tcp --dport 6666:6668 -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p udp --dport 6666:6668 -j MARK --set-mark 0x800

# MINIGRY ONLINE
iptables -t mangle -A PREROUTING -p tcp --dport 5000:5100 -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p udp --dport 5000:5100 -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p tcp --dport 17000:17100 -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p udp --dport 17000:17100 -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p tcp --dport 8000:8100 -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p udp --dport 8000:8100 -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p tcp --dport 9081:9100 -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p udp --dport 9081:9100 -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p tcp --dport 3724:3724 -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p udp --dport 3724:3724 -j MARK --set-mark 0x800

# TIBIA (GRA ONLINE)
iptables -t mangle -A PREROUTING -p tcp --dport 7171 -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p udp --dport 7171 -j MARK --set-mark 0x800

# Lineage2 (GRA ONLINE)
iptables -t mangle -A PREROUTING -p tcp --dport 2106 -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p udp --dport 2106 -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p tcp --dport 7777 -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p udp --dport 7777 -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p tcp --dport 2009 -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p udp --dport 2009 -j MARK --set-mark 0x800

# SKYPE
iptables -t mangle -A PREROUTING -p tcp --dport 5555 -j MARK --set-mark 0x850
iptables -t mangle -A PREROUTING -p udp --dport 5555 -j MARK --set-mark 0x850

# Chat WP
iptables -t mangle -A PREROUTING -p tcp --dport 5579 -j MARK --set-mark 0x800
iptables -t mangle -A PREROUTING -p udp --dport 5579 -j MARK --set-mark 0x800

# ZACHOWANIE ZAZNACZEN DLA POTOMNYCH
iptables -t mangle -A PREROUTING -p tcp -m mark --mark 0x800 -j CONNMARK --save-mark
#iptables -t mangle -A PREROUTING -p tcp -m mark --mark 0x700 -j CONNMARK --save-mark #Zmienione
iptables -t mangle -A PREROUTING -p tcp -m mark --mark 0x850 -j CONNMARK --save-mark

plik /etc/iproute2/rt_tables wygląda następująco:
#
# reserved values
#
255 local
254 main
253 default
248 ip_zew
251 www1
250 www2
#249 www3
#222 222
#204 204
#203 203
#202 202
#201 201
0 unspec
#
# local
#
#1 inr.ruhep


Na górę
 Wyświetl profil  
 
Wyświetl posty nie starsze niż:  Sortuj wg  
Nowy temat Odpowiedz w temacie  [ Posty: 1 ] 

Strefa czasowa UTC+2godz.


Kto jest online

Użytkownicy przeglądający to forum: Obecnie na forum nie ma żadnego zarejestrowanego użytkownika i 76 gości


Nie możesz tworzyć nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz dodawać załączników

Szukaj:
Przejdź do:  
cron
Technologię dostarcza phpBB® Forum Software © phpBB Group
Hosting: Compus-Net
RobertKonik.pl