🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

7 total messages Started by KZ Thu, 14 Oct 2010 10:53
altq co zrobile zle - dlugie
#21868
Author: KZ
Date: Thu, 14 Oct 2010 10:53
150 lines
5808 bytes
witam
dopadlem w necie taka konfiguracje na router

pf.conf

ip_gate =    "80.  ......"
ext_if =     "xl0"
flag1 =""
flag = "flags S/SA keep state (source-track global, max-src-states 100,
if-bound)"
int_if =     "xl1"
ports="{1><24,26><444,446><65535}"

prv_hosts =  "192.168.0.0/24"
unfiltered = "{lo0}"
icmp_types = "{ 0, 8, 15, 30 }"

dl =            "8192Kb"
ul =            "2240Kb"
noc_download = "1"
noc_upload   = "1"

set loginterface $ext_if
set loginterface $int_if

set optimization aggressive
set block-policy drop
set require-order yes
set limit frags 300000
scrub in all fragment reassemble
scrub out all fragment reassemble

#antispoof for $int_if
#antispoof for $ext_if
altq on $int_if hfsc bandwidth $dl queue { def \
_2 \
_3 \
_4 \
_5 \
_6 \
}

altq on $ext_if hfsc bandwidth $ul queue { defu \
_2u \
_3u \
_4u \
_5u \
_6u \
}
# Kolejki defaultowe:
queue def bandwidth 1% hfsc(default upperlimit 8192Kb)
queue defu bandwidth 1% hfsc(default upperlimit 630Kb)
 queue _2               bandwidth 1%  hfsc( upperlimit 850Kb )
 queue _2u              bandwidth 1%  hfsc( upperlimit 180Kb )
 queue _3               bandwidth 1%  hfsc( upperlimit 900Kb )
 queue _3u              bandwidth 1%  hfsc( upperlimit 185Kb )
 queue _4               bandwidth 1%  hfsc( upperlimit 800Kb )
 queue _4u              bandwidth 1%  hfsc( upperlimit 185Kb )
 queue _5               bandwidth 1%  hfsc( upperlimit 800Kb )
 queue _5u              bandwidth 1%  hfsc( upperlimit 185Kb )
 queue _6               bandwidth 1%  hfsc( upperlimit 800Kb )
 queue _6u              bandwidth 1%  hfsc( upperlimit 185Kb )




#pass in quick on $ext_if inet proto udp from any port 53 to any label
"DNS-in"
pass in quick on $int_if inet proto tcp from $prv_hosts to $int_if port 22
label "ssh-int"
pass in quick on $ext_if inet proto tcp from 0.0.0.0/0 to $ext_if port 22
label "ssh-ext"
pass in quick on $ext_if inet proto { tcp, udp } from 0.0.0.0/0 to $ext_if
port 161 label "snmp"
pass in quick on $ext_if inet proto tcp from 0.0.0.0/0 to $ext_if port 80
label "ipfm-www"
pass in quick inet proto icmp all icmp-type echoreq label "passed-icmp"
modulate state
pass out quick on $ext_if inet proto icmp from $ext_if to any keep state
icmp-type $icmp_types label "snmp"
block in quick on $ext_if inet proto tcp from any to any port
{1080,3128,4588,6588,445,3306,134 >< 140} label "ms-ds-ext"
block in quick on $ext_if inet proto udp from any to any port
{1080,3128,4588,6588,445,3306,134 >< 140} label "ms-ds-ext"
block in quick on $int_if inet proto tcp from any to any port
{1080,3128,4588,6588,445,3306,134 >< 140} label "ms-ds"
block in quick on $int_if inet proto udp from any to any port
{1080,3128,4588,6588,445,3306,134 >< 140} label "ms-ds"

pass quick on $unfiltered label "loopback"
block in quick on $ext_if inet from any to 255.255.255.255 label
"broadcast"
block in all label "blocked"

pass in quick on $int_if inet proto {tcp,udp} from 192.168.0.2 to any port
$ports $flag queue _2u  label _2u
pass out quick on $int_if from any to 192.168.0.2  $flag queue _2  label _2
pass in quick on $int_if inet proto {tcp,udp} from 192.168.0.3 to any port
$ports $flag queue _3u  label _3u
pass out quick on $int_if from any to 192.168.0.3  $flag queue _3  label _3
pass in quick on $int_if inet proto {tcp,udp} from 192.168.0.4 to any port
$ports $flag queue _4u  label _4u
pass out quick on $int_if from any to 192.168.0.4  $flag queue _4  label _4
pass in quick on $int_if inet proto {tcp,udp} from 192.168.0.5 to any port
$ports $flag queue _5u  label _5u
pass out quick on $int_if from any to 192.168.0.5  $flag queue _5  label _5
pass in quick on $int_if inet proto {tcp,udp} from 192.168.0.6 to any port
$ports $flag queue _6u  label _6u
pass out quick on $int_if from any to 192.168.0.6  $flag queue _6  label _6

block in quick on $int_if  from any to any
pass in quick on $int_if from any to any label default
pass out quick on $int_if from any to any label default-upload
pass out on $ext_if from ($ext_if) to any keep state

antispoof for $int_if
antispoof for $ext_if

-altq dodane i skopilowane do jadra
device          pf
device          pflog
device          pfsync

#ALTQ
options         ALTQ
options         ALTQ_CBQ
options         ALTQ_RED
options         ALTQ_RIO
options         ALTQ_HFSC
options         ALTQ_CDNR
options         ALTQ_PRIQ

#FIREWALL
options         IPFIREWALL
options         IPFIREWALL_VERBOSE
options         IPFIREWALL_FORWARD
options         IPFIREWALL_VERBOSE_LIMIT=100
options         IPFIREWALL_DEFAULT_TO_ACCEPT
#options         IPV6FIREWALL
#options         IPV6FIREWALL_VERBOSE
#options         IPV6FIREWALL_VERBOSE_LIMIT=100
#options         IPV6FIREWALL_DEFAULT_TO_ACCEPT
options         IPSTEALTH
options         IPFILTER
options         IPFILTER_LOG
options         IPDIVERT


wszystko niby dziala tylko nie tnie to podanych wartosci
moze podacie mi kilka uwag co jest zle 
Re: altq co zrobile zle - dlugie
#21869
Author: Tomasz Sowa
Date: Sat, 16 Oct 2010 00:54
116 lines
5161 bytes
Dnia Thu, 14 Oct 2010 12:53:36 +0200, KZ napisał(a):

> dopadlem w necie taka konfiguracje na router

Lubie ludzi z poczuciem humoru.

> # Kolejki defaultowe:
> queue def bandwidth 1% hfsc(default upperlimit 8192Kb)
> queue defu bandwidth 1% hfsc(default upperlimit 630Kb)

Upewnij się że te limity masz lekko mniejsze niż fizyczne możliwości,
tak na około 5-10 procent wystarczy, w przeciwnym wypadku pakiety
zaczną się kolejkować po stronie providera i nici z twojego 
priorytetowania.

> queue _2               bandwidth 1%  hfsc( upperlimit 850Kb )
> queue _2u              bandwidth 1%  hfsc( upperlimit 180Kb )
> queue _3               bandwidth 1%  hfsc( upperlimit 900Kb )
> queue _3u              bandwidth 1%  hfsc( upperlimit 185Kb )
> queue _4               bandwidth 1%  hfsc( upperlimit 800Kb )
> queue _4u              bandwidth 1%  hfsc( upperlimit 185Kb )
> queue _5               bandwidth 1%  hfsc( upperlimit 800Kb )
> queue _5u              bandwidth 1%  hfsc( upperlimit 185Kb )
> queue _6               bandwidth 1%  hfsc( upperlimit 800Kb )
> queue _6u              bandwidth 1%  hfsc( upperlimit 185Kb )

Nie odróżnisz limitu downloadu 850Kb i 900Kb, nie masz wielkiego 
wpływu na download, ile wysyłający do ciebie będzie chciał wysłać
tyle wyśle, w przypadku tcp poprostu nie dostanie w odpowiedniej
szybkości odpowiedzi (pakietów kontrolnych) i przestanie na chwile
wysyłać. Ale już w przypadku udp i icmp to będzie słał ile fabryka
dała.

> #pass in quick on $ext_if inet proto udp from any port 53 to any label "DNS-in"

co chciałeś tą regułką złapać?

> pass in quick on $int_if inet proto tcp from $prv_hosts to $int_if port 22 label "ssh-int"

taki ruch aż się prosi o priorytet, nie wygodnie jest mieć
płynną konsole?

> pass in quick on $ext_if inet proto tcp from 0.0.0.0/0 to $ext_if port 22 label "ssh-ext"

a tą regułą co chcesz złapać?

[ciach]

> pass in quick on $int_if inet proto {tcp,udp} from 192.168.0.2 to any port $ports $flag queue _2u  label _2u
> pass out quick on $int_if from any to 192.168.0.2  $flag queue _2  label _2

nie zadziała, źle przypisujesz pakiety do kolejek
pierwsza reguła stworzy regułkę stanu (masz flagę keep state) 
i przy pakietach powracających zostanie wykorzystana reguła stanu
która nic nie będzie wiedziała o priorytecie downloadu
i wrzuci wszystko do domyślnej kolejki
(firewall nawet nie użyje drugiej reguły)

W skrócie to się robi tak:
pass in  quick on $int_if inet proto tcp from 192.168.0.2 to any port $ports $flag queue _2
pass out quick on $ext_if inet proto tcp from $ext_if to any port $ports $flag queue _2u

Dla reguły zezwalającej na interfejsie wewnętrznym pakiety przypisujesz
do kolejki _2 (download). One wpadną tam jak będą wracać z uwagi że pf to
state-full firewall. Przy pakiecie wyjściowym jawnie ustawiasz kolejkę
wyjściową. 

Możesz także użyć tagowania (parametry: tag, tagged)

[reszta kolejek też do poprawy]


> -altq dodane i skopilowane do jadra
> device          pf
> device          pflog
> device          pfsync

dobrze

> #ALTQ
> options         ALTQ
> options         ALTQ_CBQ
> options         ALTQ_RED
> options         ALTQ_RIO
> options         ALTQ_HFSC
> options         ALTQ_CDNR
> options         ALTQ_PRIQ

z powyższego wykorzystujesz tylko ALTQ i ALTQ_HFSC

> #FIREWALL
> options         IPFIREWALL
> options         IPFIREWALL_VERBOSE
> options         IPFIREWALL_FORWARD
> options         IPFIREWALL_VERBOSE_LIMIT=100
> options         IPFIREWALL_DEFAULT_TO_ACCEPT
> #options         IPV6FIREWALL
> #options         IPV6FIREWALL_VERBOSE
> #options         IPV6FIREWALL_VERBOSE_LIMIT=100
> #options         IPV6FIREWALL_DEFAULT_TO_ACCEPT
> options         IPSTEALTH
> options         IPFILTER
> options         IPFILTER_LOG
> options         IPDIVERT

> wszystko niby dziala tylko nie tnie to podanych wartosci
> moze podacie mi kilka uwag co jest zle 

Zdecyduj się którego firewalla używasz. IPFIREWALL ci 
nie potrzebny, usuń te ostatnie reguły i przekompiluj jądro.
Nie widzę reguł do natowania, więc w tej chwili coś 
innego zaczeło ci robić nata. Podsumowując: wszystko do poprawy.

-- 
Tomek
http://www.ttmath.org
Re: altq co zrobile zle - dlugie
#21870
Author: Tomasz Sowa
Date: Sat, 16 Oct 2010 11:08
15 lines
1502 bytes
Dnia Sat, 16 Oct 2010 02:54:55 +0200, Tomasz Sowa napisał(a):

> W skrócie to się robi tak:
> pass in  quick on $int_if inet proto tcp from 192.168.0.2 to any port $ports $flag queue _2
> pass out quick on $ext_if inet proto tcp from $ext_if to any port $ports $flag queue _2u

tu jednak bez tagowania się nie obejdzie bo masz różne kolejki
uploadu dla różnych hostów, trzeba je odróżnić, poprawka:

pass in  quick on $int_if inet proto tcp from 192.168.0.2 to any port $ports $flag queue _2 tag host2
pass out quick on $ext_if inet proto tcp from $ext_if to any port $ports $flag queue _2u tagged host2

-- 
Tomek
http://www.ttmath.org
Re: altq co zrobile zle - dlugie
#21871
Author: KZ
Date: Thu, 21 Oct 2010 11:08
23 lines
1906 bytes
Dnia Sat, 16 Oct 2010 13:08:57 +0200, Tomasz Sowa napisał(a):

> Dnia Sat, 16 Oct 2010 02:54:55 +0200, Tomasz Sowa napisał(a):
> 
>> W skrócie to się robi tak:
>> pass in  quick on $int_if inet proto tcp from 192.168.0.2 to any port $ports $flag queue _2
>> pass out quick on $ext_if inet proto tcp from $ext_if to any port $ports $flag queue _2u
> 
> tu jednak bez tagowania się nie obejdzie bo masz różne kolejki
> uploadu dla różnych hostów, trzeba je odróżnić, poprawka:
> 
> pass in  quick on $int_if inet proto tcp from 192.168.0.2 to any port $ports $flag queue _2 tag host2
> pass out quick on $ext_if inet proto tcp from $ext_if to any port $ports $flag queue _2u tagged host2



witam
po zmianie i przetestowaniu podanych przez ciebie regolek
ciecie dziala tylko mam maly problem po 10 minutach pracy
nie dziala dns 
czyli ping 8.8.8.8 - dziala
a juz ping www.wp.pl nie 
i routing przestaje dzialac tzn nie dziala /nie przeuszcza dns/
Re: altq co zrobile zle - dlugie
#21872
Author: Tomasz Sowa
Date: Fri, 22 Oct 2010 03:03
17 lines
1532 bytes
Dnia Thu, 21 Oct 2010 13:08:27 +0200, KZ napisał(a):

> po zmianie i przetestowaniu podanych przez ciebie regolek
> ciecie dziala tylko mam maly problem po 10 minutach pracy
> nie dziala dns 
> czyli ping 8.8.8.8 - dziala
> a juz ping www.wp.pl nie 
> i routing przestaje dzialac tzn nie dziala /nie przeuszcza dns/

Nie działa dns z komputerów za natem czy z serwera?

Zresztą to musi być coś innego niż pf skoro przez 10 minut działa a później
nie, ale pokaż regułki dotyczące dnsów, albo wklej cały pf.conf tutaj
http://pastebin.com/ przyjrze się temu.

-- 
Tomek
Re: altq co zrobile zle - dlugie
#21873
Author: KZ
Date: Tue, 26 Oct 2010 16:03
186 lines
8680 bytes
Dnia Fri, 22 Oct 2010 05:03:30 +0200, Tomasz Sowa napisał(a):

> Dnia Thu, 21 Oct 2010 13:08:27 +0200, KZ napisał(a):
> 
>> po zmianie i przetestowaniu podanych przez ciebie regolek
>> ciecie dziala tylko mam maly problem po 10 minutach pracy
>> nie dziala dns 
>> czyli ping 8.8.8.8 - dziala
>> a juz ping www.wp.pl nie 
>> i routing przestaje dzialac tzn nie dziala /nie przeuszcza dns/
> 
> Nie działa dns z komputerów za natem czy z serwera?
> 
> Zresztą to musi być coś innego niż pf skoro przez 10 minut działa a później
> nie, ale pokaż regułki dotyczące dnsów, albo wklej cały pf.conf tutaj
> http://pastebin.com/ przyjrze się temu.

    ip_gate =    "9.9.9.9"
    ext_if =     "xl0"
    flag1 =""
    flag = "flags S/SA keep state (source-track global, max-src-states 100,
if-bound)"
    int_if =     "xl1"
    ports="{1><24,26><444,446><65535}"
     
     
    prv_hosts =  "192.168.0.0/24"
    unfiltered = "{lo0}"
    icmp_types = "{ 0, 8, 15, 30 }"
     
    dl =            "8192Kb"
    ul =            "740Kb"
    noc_download = "1"
    noc_upload   = "1"
     
    set loginterface $ext_if
    set loginterface $int_if
     
    set optimization aggressive
    set block-policy drop
    set require-order yes
    set limit frags 300000
    scrub in all fragment reassemble
    scrub out all fragment reassemble
     
    #antispoof for $int_if
    #antispoof for $ext_if
     
    altq on $int_if hfsc bandwidth $dl queue { def \
    _2 \
    _3 \
    _4 \
    _5 \
    _6 \
    _7 \
    _8 \
    _9 \
    _10 \
    }
    altq on $ext_if hfsc bandwidth $ul queue { defu \
    _2u \
    _3u \
    _4u \
    _5u \
    _6u \
    _7u \
    _8u \
    _9u \
    _10u \
    }
    queue def bandwidth 1% hfsc(default upperlimit 8192Kb)
    queue defu bandwidth 1% hfsc(default upperlimit 630Kb)
     queue _2               bandwidth 1%  hfsc( upperlimit 850Kb )
     queue _2u              bandwidth 1%  hfsc( upperlimit 80Kb )
     queue _3               bandwidth 1%  hfsc( upperlimit 900Kb )
     queue _3u              bandwidth 1%  hfsc( upperlimit 85Kb )
     queue _4               bandwidth 1%  hfsc( upperlimit 800Kb )
     queue _4u              bandwidth 1%  hfsc( upperlimit 85Kb )
     queue _5               bandwidth 1%  hfsc( upperlimit 800Kb )
     queue _5u              bandwidth 1%  hfsc( upperlimit 85Kb )
     queue _6               bandwidth 1%  hfsc( upperlimit 800Kb )
     queue _6u              bandwidth 1%  hfsc( upperlimit 85Kb )
     queue _7               bandwidth 1%  hfsc( upperlimit 500Kb )
     queue _7u              bandwidth 1%  hfsc( upperlimit 360Kb )
     queue _8               bandwidth 1%  hfsc( upperlimit 800Kb )
     queue _8u              bandwidth 1%  hfsc( upperlimit 95Kb )
     queue _9               bandwidth 1%  hfsc( upperlimit 500Kb )
     queue _9u              bandwidth 1%  hfsc( upperlimit 85Kb )
     queue _10              bandwidth 1%  hfsc( upperlimit 800Kb )
     queue _10u             bandwidth 1%  hfsc( upperlimit 85Kb )
     
    nat on $ext_if from $prv_hosts -> $ip_gate
     
     
    pass out quick on $ext_if inet from {$int_if} to any flags S/SA keep
state
    pass in quick on $int_if inet proto tcp from any to 192.168.0.1 port
8080
    pass in quick on $int_if inet proto tcp from any to 127.0.0.1 port 8080
    #pass in quick on $ext_if inet proto udp from any port 53 to any label
"DNS-in"
    pass in quick on $int_if inet proto tcp from $prv_hosts to $int_if port
22 label "ssh-int"
    pass in quick on $ext_if inet proto tcp from 0.0.0.0/0 to $ext_if port
22 label "ssh-ext"
    pass in quick on $ext_if inet proto { tcp, udp } from 0.0.0.0/0 to
$ext_if port 161 label "snmp"
    pass in quick on $ext_if inet proto tcp from 0.0.0.0/0 to $ext_if port
80 label "ipfm-www"
    pass in quick inet proto icmp all icmp-type echoreq label "passed-icmp"
modulate state
    pass out quick on $ext_if inet proto icmp from $ext_if to any keep
state icmp-type $icmp_types label "snmp"
    block in quick on $ext_if inet proto tcp from any to any port
{1080,3128,4588,6588,445,3306,134 >< 140} label "ms-ds-ext"
    block in quick on $ext_if inet proto udp from any to any port
{1080,3128,4588,6588,445,3306,134 >< 140} label "ms-ds-ext"
    block in quick on $int_if inet proto tcp from any to any port
{1080,3128,4588,6588,445,3306,134 >< 140} label "ms-ds"
    block in quick on $int_if inet proto udp from any to any port
{1080,3128,4588,6588,445,3306,134 >< 140} label "ms-ds"
     
    pass quick on $unfiltered label "loopback"
    block in quick on $ext_if inet from any to 255.255.255.255 label
"broadcast"
    block in all label "blocked"
     
     
    pass in quick on $int_if inet proto {tcp,udp} from 192.168.0.2 to any
port $ports $flag queue _2 tag host2
    pass out quick on $ext_if inet proto {tcp,udp} from $ext_if to any port
$ports $flag queue _2u tagged host2
     
    pass in quick on $int_if inet proto {tcp,udp} from 192.168.0.3 to any
port $ports $flag queue _3 tag host3
    pass out quick on $ext_if inet proto {tcp,udp} from $ext_if to any port
$ports $flag queue _3u tagged host3
     
     
    pass in quick on $int_if inet proto {tcp,udp} from 192.168.0.4 to any
port $ports $flag queue _4 tag host4
    pass out quick on $ext_if inet proto {tcp,udp} from $ext_if to any port
$ports $flag queue _4u tagged host4
     
    pass in quick on $int_if inet proto {tcp,udp} from 192.168.0.5 to any
port $ports $flag queue _5 tag host5
    pass out quick on $ext_if inet proto {tcp,udp} from $ext_if to any port
$ports $flag queue _5u tagged host5
     
    pass in quick on $int_if inet proto {tcp,udp} from 192.168.0.6 to any
port $ports $flag queue _6 tag host6
    pass out quick on $ext_if inet proto {tcp,udp} from $ext_if to any port
$ports $flag queue _6u tagged host6
     
    pass in quick on $int_if inet proto {tcp,udp} from 192.168.0.7 to any
port $ports $flag queue _7 tag host7
    pass out quick on $ext_if inet proto {tcp,udp} from $ext_if to any port
$ports $flag queue _7u tagged host7
     
    pass in quick on $int_if inet proto {tcp,udp} from 192.168.0.8 to any
port $ports $flag queue _8 tag host8
    pass out quick on $ext_if inet proto {tcp,udp} from $ext_if to any port
$ports $flag queue _8u tagged host8
     
    pass in quick on $int_if inet proto {tcp,udp} from 192.168.0.9 to any
port $ports $flag queue _9 tag host9
    pass out quick on $ext_if inet proto {tcp,udp} from $ext_if to any port
$ports $flag queue _9u tagged host9
     
    pass in quick on $int_if inet proto {tcp,udp} from 192.168.0.10 to any
port $ports $flag queue _10 tag host10
    pass out quick on $ext_if inet proto {tcp,udp} from $ext_if to any port
$ports $flag queue _10u tagged host10
     
    #pass in log on $ext_if inet proto tcp from any to $int_if port 1:65535
keep state
     
    #block in quick on $int_if  from any to any
    pass in quick on $int_if from any to any label default
    pass out quick on $int_if from any to any label default-upload
    pass out on $ext_if from ($ext_if) to any keep state
     
    antispoof for $int_if
    antispoof for $ext_if

to dziala ale strasznie muli
Re: altq co zrobile zle - dlugie
#21874
Author: Tomasz Sowa
Date: Thu, 28 Oct 2010 22:44
33 lines
1860 bytes
Dnia Tue, 26 Oct 2010 18:03:04 +0200, KZ napisał(a):

>     ip_gate =    "9.9.9.9"
>     ext_if =     "xl0"
>     flag1 =""
>     flag = "flags S/SA keep state (source-track global, max-src-states 100, if-bound)"

wyrzuć: source-track global, max-src-states 100
[...]

>     set loginterface $ext_if
>     set loginterface $int_if
>      
>     set optimization aggressive
>     set block-policy drop
>     set require-order yes
>     set limit frags 300000
>     scrub in all fragment reassemble
>     scrub out all fragment reassemble
>      
>     #antispoof for $int_if
>     #antispoof for $ext_if

z powyższego zostaw tylko set block-policy drop
[...]
    
> to dziala ale strasznie muli

reszta wygląda w miare dobrze, chociaż można te regułki czytelniej zapisać

-- 
Tomek
http://www.ttmath.org
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads