firewall - · pdf fileprotect against connections that bypass it ... reverse proxy non...

45
FIREWALL 1

Upload: truongnhi

Post on 08-Mar-2018

230 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

FIREWALL

1

Page 2: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

Firewall

� NON è un muro di fuoco, è un muro tagliafuoco che ha il compito di isolare e compartimentare una struttura.compartimentare una struttura.

� Il firewall è l'insieme delle difese perimetrali, hardware e software, costituito da uno o più dispositivi.

2

Page 3: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

Firewall

� restricts entry to carefully controlled points

� prevents attackers from getting close to defensesdefenses

� restricts exits to carefully controlled points

3

Page 4: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

Firewall

� Combination of hardware and software to regulate traffic between an internal network

and an external network (Internet)and an external network (Internet)

� Benefits of being “connected” while minimizing the risks of threats

4

Page 5: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

Firewall

� What can a firewall do?� Focus security decisions

� Enforce security policies

� Log Internet activity

� What can’t a firewall do?� What can’t a firewall do?� Protect against malicious insiders

� Protect against connections that bypass it

� Protect against completely new threats

� Protect against viruses and worms

� Set itself up correctly

5

Page 6: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

Firewall

� Problems with firewalls� Interfere with the Internet end-to-end

communication modelcommunication model

� Create false sense of perfect security

� Increase inconvenience for users

6

Page 7: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

Firewall Technologies

� Packet filtering

� Proxy servers

� Network address translation

7

Page 8: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

Packet Filtering

� Implemented through a screening router� Router: can the packet be routed to its destination?

� Screening router: should the packet be routed to its destination?

� Decision based on information in the IP packet header

� Decision based on information in the IP packet header� IP source address

� IP destination address

� Protocol (TCP, UDP, ICMP)

� Source port number

� Destination port number

� Packet size

8

Page 9: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

Packet Filtering

� Additional information� Interface the packet arrives on

� Interface the packet will go out on

� State information� Is the packet a response to an earlier packet?� Is the packet a response to an earlier packet?

� Number of recent packets seen from the same host

� Is the packet identical to a recently seen packet?

� Is the packet a fragment?

9

Page 10: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

Packet Filtering

10

Page 11: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

Packet Filtering

� Advantages� One screening router can protect the entire

network

� Extremely efficient

� Widely available

11

� Widely available

� Disadvantages� Hard to configure

� Reduces router performance

� Limited in the range of policies that can be implemented

Page 12: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

Proxy Servers

� Specialized application programs for Internet services (HTTP, FTP, telnet, etc.)� Proxy server

� Proxy client

� Need a mechanism to restrict direct � Need a mechanism to restrict direct communication between the internal and external networks

� Typically combined with caching for performance

12

Page 13: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

Dual-Homed Host Proxy

Servers

13

Page 14: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

Proxy Servers

� Advantages� Can perform user-level authentication

� Can do intelligent (application specific) filtering

� Can be combined with caching� Can be combined with caching

� Can do good logging

� Disadvantages� Typically lag behind their nonproxied equivalents

� Require different servers for each service

� Require modifications to clients

14

Page 15: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

Network Address Translation

� Allows a network to use a set of addresses internally and a different set of addresses externally

� Invented not for security but for conserving IP � Invented not for security but for conserving IP addresses

� Typically implemented within a router

15

Page 16: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

Network Address Translation

16

Page 17: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

Network Address Translation

� Advantages� Enforces firewall control over outbound traffic

� Restricts incoming traffic (no spontaneous connections)

� Hides structure and details of internal network� Hides structure and details of internal network

� Disadvantages� Interferes with some encryption-based techniques

� Dynamic allocation of addresses interferes with logging

� Internal network cannot host externally-visible services (requires port mapping)

17

Page 18: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

Network Address Translation

18

Page 19: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

SNAT

19

Page 20: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

SNAT

� Le connessioni vengono alterate in maniera da presentare verso l’esterno uno o più indirizzi IP diversi da quelli originali

� NAT dinamico (IP masquerading)� le connessioni generate da un insieme di computer

vengono viste all’esterno con un solo indirizzo IP� non viene modificato solo l’indirizzo IP ma anche le porte � non viene modificato solo l’indirizzo IP ma anche le porte

TCP e UDP delle connessioni� il router gestisce una tabella della corrispondenza tra porta

esterna e indirizzo e porta interna� permette di gestire solo connessioni originate all’interno

della rete

� NAT statico� assegnare ad un host uno specifico indirizzo IP pubblico� viene modificato solo l’indirizzo IP ma non la porta di connessione

20

Page 21: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

DNAT

21

Page 22: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

DNAT� Le connessioni effettuate dagli host vengono modificate per essere

ridirezionate verso indirizzi ip diversi da quelli originali� Port forwarding

� in una situazione di IP masquerading, può essere necessario permettere connessioni verso host interni originate dall’esterno

� le connessioni indirizzate verso una specifica porta vengono ridirezionatead un particolare host della rete interna

� Bilanciamento del carico� il traffico viene ridirezionato ad un indirizzo scelto tra un insieme di

serverserver� permette di bilanciarne il carico di lavoro sei server

� High-availability� E’ presente un server principale e almeno un server secondario� Il router può rilevare il mancato funzionamento del server principale� Per mantenere il corretto funzionamento del servizio redireziona il

traffico verso il server secondario

� Proxy trasparente� ridireziona le connessioni ad un server proxy� Permette di sfruttare il sistema di caching fornito dal proxy� Non necessita di configurazioni sui client

22

Page 23: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

NAT

� Limita il principio della comunicazione “anyto any” (da qualsiasi host a qualsiasi host)

� L’instradamento non dipende più solo dall’indirizzo IP di destinazione, ma da altre caratteristiche presenti a livello di trasporto

� Le configurazioni NAT possono diventare � Le configurazioni NAT possono diventare molto complesse da amministrare

� L’apparato deve tenere una tabella delle connessioni attive� Viola il principio per cui i router non devono

mantenere uno stato relativo al traffico che li attraversa

23

Page 24: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

Screening Router

24

Page 25: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

Dual-homed Host

25

Page 26: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

Screened Host

26

Page 27: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

Screened Subnet

27

Page 28: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

Reverse Proxy

28

Page 29: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

Reverse Proxy

� Non è un firewall

� Protegge contro attacchi di tipo DoS� Il proxy analizza i pacchetti in arrivo e scarta

quelli non validi

� La presenza dei proxy permette di � La presenza dei proxy permette di utilizzare un sistema di caching

� Avere due proxy consente di effettuare una politica di load-balancing

29

Page 30: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

NETFILTER/IPTABLES

30

Page 31: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

Netfilter: cos'è

� È un packet filter a livello kernel per linux.� È un framework composto dal “filtro” residente

in kernelspace e dai tool di configurazione in user-space.

� Accetta o rifiuta pacchetti basandosi su un set di regole.regole.

� Esamina pacchetti confrontando sorgente, destinazione, porte e altri parametri a seconda del protocollo in esame.

� Fornisce ispezione stateful dei pacchetti.� Supporta NAT, redirezione delle porte e

alterazione dei pacchetti.

31

Page 32: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

Netfilter: user-space tools

� linux 2.0 – ipfwadm� semplice (“insert”, “remove”), struttura lineare: ogni regola deve

essere processata finché non si ottiene un match o si raggiunge il default

� non estensibile� stateless

� linux 2.2 – ipchains� più feature (QOS, “replace”, negazioni), struttura ad albero: una � più feature (QOS, “replace”, negazioni), struttura ad albero: una

regola può saltare da una catena a un'altra� non molto più estensibile� ancora stateless

� linux 2.4/2.6 – iptables� molte più feature (ipv4, ipv6, connection tracking, NAT, PORTFW,

log, ...)

� flessibile ed estensibile (moduli)� stateful filtering

32

Page 33: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

IPTables: Tabelle

iptables [-t TABELLA] -A CATENA [-m MODULO] REGOLA... -j AZIONE

� Filter� tabella di default se “-t TABLE” non specificato� filtra il traffico in ingresso/uscita/transito� catene: INPUT, OUTPUT, FORWARD

� Nat� Nat� Network AddressTranslation, riscrittura della

sorgente/destinazione del pacchetto� catene: PREROUTING, OUTPUT, POSTROUTING

� Mangle� alterazione dei pacchetti (TOS, MARK, ...)� catene: PREROUTING, INPUT, OUTPUT, FORWARD,

POSTROUTING

33

Page 34: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

IPTables: Catene

� Una catena è una ACL costituita da una lista

sequenziale di regole.

� INPUT: presente nelle tabelle filter e mangle, processa pacchetti destinati all'host

� OUTPUT: presente nelle tabelle filter, nat e � OUTPUT: presente nelle tabelle filter, nat e mangle, processa pacchetti originati dall'host

� FORWARD: presente nelle tabelle filter e mangle, processa il traffico in transito, ovvero i pacchetti instradati attraverso l'host

34

Page 35: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

IPTables: Catene

� PREROUTING : presente nelle tabelle nat e mangle, processa i pacchetti prima che il kernel ne calcoli il percorso di routing

� POSTROUTING: presente nelle tabelle nat e mangle, processa i pacchetti dopo che il mangle, processa i pacchetti dopo che il kernel ha calcolo il percorso di routing

� Altre catene possono essere create e aggiunte a piacimento.

35

Page 36: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

IPTables: Catene ( sintassi)

� Ogni catena built-in ha una policy di default che indica l'azione da compiere per i pacchetti che non corrispondono ad alcuna regola. Le policy possono essere: ACCEPT, REJECT, DROP.

� Le possibili operazioni sulle catene sono:� cambiare la policy di una catena: “iptables -P CATENA POLICY”

(iptables -P INPUT DROP)� creare una nuova catena: “iptables -N NUOVA_CATENA”� creare una nuova catena: “iptables -N NUOVA_CATENA”

� cancellare una catena (non built-in): “iptables -X NUOVA_CATENA”

� rimuovere tutte le regole da una catena: “iptables -F CATENA”

� azzerare i contatori associati a una catena: “iptables -Z CATENA”

� rinominare una catena: “iptables -E VECCHIO_NOMENUOVO_NOME”

� lista delle regole associate ad una catena: “iptables -L CATENA”

36

Page 37: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

IPTables: Regole

� Ogni regola definisce le caratteristiche di un pacchetto da controllare e l'azione da compiere nel caso ci sia un match.

� Alcuni dei parametri disponibili sono:� interfaccia di rete su cui transita il pacchetto� IP sorgente, IP destinazione� porte sorgente e destinazione (per TCP e UDP)� porte sorgente e destinazione (per TCP e UDP)� flag di connessione (TCP)� tipo e codice ICMP� stato della connessione

� se l'azione associata alla regola è "terminante", il match termina l'analisi del pacchetto, altrimenti l'analisi prosegue con la regola successiva. L'azione può anche essere il jump ad un'altra catena.

37

Page 38: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

IPTables: Regole (sintassi)

� aggiungere una regola in fondo a una catena: “iptables –A CATENA REGOLA...”

iptables -A INPUT -p tcp --dport 22 -j ACCEPT

� inserire una regola in un punto specifico della catena: “iptables –ICATENA POSIZIONE REGOLA”

iptables -I INPUT 1 -i lo -j ACCEPT

� cancellare una regola: “iptables -D CATENA POSIZIONE” o “iptables -D CATENA REGOLA”

iptables -D INPUT 2

iptables -D INPUT -p tcp --dport 22 -j ACCEPT

� rimpiazzare una regola: “iptables -R CATENA POSIZIONE NUOVA_REGOLA...”

iptables -R INPUT 2 -p tcp --dport 22 --syn -j ACCEPT

38

Page 39: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

IPTables: rule order

� The order of rules is very important. Rules are applied to the packets in the order in which they were added (within the context of each individualtable and chain).

� As an example, if you append a rule to the filter table’s INPUT chain to DROP packets on port 22, and then append another rule to ACCEPT packets on and then append another rule to ACCEPT packets on port 22 from a specific IP address, the packets will still be dropped because they will match the DROP rule before they match the ACCEPT rule. The first matching rule “wins”.

� The last bit about “first packet will continue on to the next rule in the chain. matching rule wins” has an exception though: if the matching rule has a “non-terminating” target (es. LOG)

39

Page 40: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

IPTables: Azioni

iptables [-t TABELLA] -A CATENA [-m MODULO] REGOLA... -j AZIONE

� ACCEPT - il pacchetto viene accettato� REJECT - il pacchetto viene rifiutato informando il sender� DROP - il pacchetto viene ignorato� RETURN - il pacchetto ritorna alla catena originale

� L'azione può essere una qualunque altra catena o una funzione particolare come “LOG/ULOG/TARPIT/...” (filter), “MARK/...” (mangle), “DNAT/SNAT/REDIRECT/...” (nat)

� Come nel caso di LOG, un'azione può essere “non terminante”, l'analisi continua con la regola successiva.

40

Page 41: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

IPTables: Parametri

(sintassi)iptables [-t TABELLA] -A CATENA [-m MODULO] REGOLA... -j

AZIONE

� “-p [!] PROTOCOLLO” indica il protocollo (-p tcp, -p 6).� “-s [!] IP_SORGENTE[/NETMASK]” specifica l'indirizzo (o il

blocco di indirizzi) della sorgente (-s 10.0.0.1, -s 10.0.0.0/255.0.0.0, -s 10.0.0.0/8).“-d [!] IP_DESTINAZIONE[/NETMASK]” specifica l'indirizzo � “-d [!] IP_DESTINAZIONE[/NETMASK]” specifica l'indirizzo (o il blocco di indirizzi) della destinazione (-d 10.0.0.1, ...)

� “-i [!] INTERFACCIA” specifica l'interfaccia di rete dalla quale entra il pacchetto (-i lo, -i eth0, -i eth1, ...)

� “-o [!] INTERFACCIA” specifica l'interfaccia di rete dalla quale esce il pacchetto (-o lo, ...)

� “-m MODULO”: carica il modulo di estensione (-m tcp, -m state, -m recent, ...)

41

Page 42: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

IPTables: Parametri (sintassi)

� Per ogni protocollo esistono parametri particolari, per TCP e UDP, ad esempio, possiamo usare:� “--sport [!] PORTA” per indicare la porta sorgente� “--dport [!] PORTA” per indicare la porta di destinazione

� Per il protocollo TCP, caricando il modulo opportuno (-m tcp), è possibile controllare i flag di connessione:� “[!] --syn” indica che il flag SYN e settato mentre FIN, RST e ACK

non lo sono (richiesta nuova connessione)non lo sono (richiesta nuova connessione)� “--tcp-flags [!] MASCHERA FLAG[,...]“ consente di controllare i

singoli bit: SYN, ACK, RST, FIN, URG, PSH. Il comando “--tcp-flags FIN,SYN,RST,ACK SYN” equivale a “--syn”.

� Per il protocollo ICMP (-m icmp), è possibile controllare il tipo e il codice del messaggio (--icmp-type echo-reply, --icmp-type time-exceeded, --icmp-type destination-unreachable, ...).

� Altri moduli abilitano altre opzioni per match più accurati su parametri aggiuntivi.

42

Page 43: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

IPTables: Moduli

iptables [-t TABELLA] -A CATENA [-m MODULO] REGOLA... -j AZIONE

Tra i vari moduli disponibili, alcuni esempi degni di nota sono:� tcp, udp, icmp, mac: abilitano opzioni aggiuntive per

relativi protocolli (-m mac --mac-source 00:11:22:33:44:55 -j ACCEPT)

� state: abilita controllo sul connection tracking� limit: limita il numero di pacchetti per unità di tempo che � limit: limita il numero di pacchetti per unità di tempo che

matchano la regola (-p icmp --icmp-type echo-request -m limit --limit 3/s -J ACCEPT)

� recent: consente di creare una lista dinamica di IP per tracciare, ed eventualmente limitare, in maniera intelligente il numero di connessioni da un host

� multiport: consente di definire più porte (--dports 80,443) o sorgente e destinazione con un unica opzione (--ports 123)

43

Page 44: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

IPTables: connection

trackingiptables [...] -m state --state STATO

� NEW: il pacchetto inizia una nuova connessione� ESTABLISHED: il pacchetto è associato a una connessione

esistente� RELATED: il pacchetto inizia una nuova connessione ma è in

relazione a una connessione già esistente (ftp-data quando una sessione ftp-control è attiva, notifiche ICMP)sessione ftp-control è attiva, notifiche ICMP)

� INVALID: il pacchetto non appartiene ad una connessione esistente

� Esempio:

iptables -A INPUT -p tcp -m tcp ! --syn -m state --state NEW -j DROPiptables -A INPUT -m state --state INVALID -j DROPiptables -A INPUT -m state --state ESTABLISHED,RELATED -j

ACCEPT

44

Page 45: FIREWALL - · PDF fileProtect against connections that bypass it ... Reverse Proxy Non è un firewall Protegge contro attacchi di tipo DoS Il proxyanalizza i pacchetti in arrivo e

IPTables: hints

� As much as possible, organize your rules so that most of your traffic will be matched by earlier rules in the ruleset. System resource usage is minimized by decreasing the number of rules that a packet hits before it matches.

� Custom chains can be useful to decrease the � Custom chains can be useful to decrease the number of rules a packet has to hit. For example, you can create separate chains for each protocol — there is no need to test UDP traffic against rules that only apply to TCP traffic.

45