Portál AbcLinuxu, 10. května 2025 08:41
Protoze v iptables nejdou psat efektivne pravidla. To lze ale porovnavat az pri pouziti a porovnani obou filtrovacich systemu. Napriklad takovy antispoof. V iptables se to dela podobne otresne jako v IPfilter. Musi se zadat rozsahy, ktere se chteji filtrovat a tech pochopitelne muze byt obrovske mnozstvi. Doporucuji vyzkouset napr. firestarter na nejake mainstream Linux distribuci, blokovat vse dovnitr, ven povolit jen co navazu a zapnout antispoof a pak v konzoli udelat 'iptables --list'. Clovek si muze v klidu zajit na kafe, protoze zacne vypisovat antispoof pro vsechny mozne rozsahy a to trva pekelne dlouho. Pri provozu pak iptables tim vsim musi prochazet pri kontrole paketu a to na rychlosti moc neprida. Nevim kdy presne ten vypis konci. Ja to po 4 minutach vzdal to cekani. V PF toho sameho dosahnu timhle :
lan_if = "fxp0"
antispoof quick for { $lan_if }
block in all
pass out
Princip detailne : Example: antispoof for fxp0 inet When a ruleset is loaded, any occurrences of the antispoof keyword are expanded into two filter rules. Assuming that interface fxp0 has IP address 10.0.0.1 and a subnet mask of 255.255.255.0 (i.e., a /24), the above antispoof rule would expand to: block in on ! fxp0 inet from 10.0.0.0/24 to any block in inet from 10.0.0.1 to any These rules accomplish two things: * Blocks all traffic coming from the 10.0.0.0/24 network that does not pass in through fxp0. Since the 10.0.0.0/24 network is on the fxp0 interface, packets with a source address in that network block should never be seen coming in on any other interface. * Blocks all incoming traffic from 10.0.0.1, the IP address on fxp0. The host machine should never send packets to itself through an external interface, so any incoming packets with a source address belonging to the machine can be considered malicious.
Jednoduche a ucinne. Neni treba placat vsechny rozsahy a zbytecne tak zatezovat firewall a zpomalovat provoz. Ted si nekdo rekne a jak asi zablokujes ostatni adresy, ktere jsou podle RFC jen pro interni provoz chytraku. No jednoduse : http://www.openbsd.org/faq/pf/tables.html#config tabulky jsou efektivni, mohou mit obrovsky pocet zaznamu a hlavne maji vysokou rychlost zpracovani a nizkou zatez.
No dobre, ale to, ze jdou v PF psat efektvne pravidla, zase nevysvetluje ten vetsi vykon oproti iptables. Kdyz budu mit rikneme:
pass in on { fxp0, ep0 } proto tcp to 192.168.1.9 port { 80, 443, 8282 } keep state
tak se to stejne v pf expanduje na neco jako:
pass in on fxp0 inet proto tcp from any to 192.168.1.9 port = http flags S/SA keep state pass in on fxp0 inet proto tcp from any to 192.168.1.9 port = https flags S/SA keep state pass in on fxp0 inet proto tcp from any to 192.168.1.9 port = 8282 flags S/SA keep state pass in on ep0 inet proto tcp from any to 192.168.1.9 port = http flags S/SA keep state pass in on ep0 inet proto tcp from any to 192.168.1.9 port = https flags S/SA keep state pass in on ep0 inet proto tcp from any to 192.168.1.9 port = 8282 flags S/SA keep state
To mi sice usetri psani, zprehledni konfiguraci, ale narocne na zpracovani pri pruchodu packetu by to melo byt stejne, jako sest pravidel otrocky napsanych v iptables, ne?
Tomas
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.