[Precedente: Pool di indirizzi e bilanciamento del carico] [Indice] [Successivo: Logging]
pass in on $int_if all tag INTERNAL_NET keep state
La tag INTERNAL_NET sarà aggiunta a ogni pacchetto che soddisfa la regola precedente.
Una tag può anche essere assegnata usando una macro. Per esempio:
name = "INTERNAL_NET"
pass in on $int_if all tag $name keep state
Ci sono un set di macro predefinite che possono anche essere usate.
Queste macro sono espanse nell'instante in cui vengono caricate le regole di configurazione e non in tempo reale.
Il tagging segue queste regole:
Consideriamo le seguenti regole come esempio.
(1) pass in on $int_if tag INT_NET keep state
(2) pass in quick on $int_if proto tcp to port 80 tag \
INT_NET_HTTP keep state
(3) pass in quick on $int_if from 192.168.1.5 keep state
Oltre ad applicare tag con le regole di filtraggio, le regole di traslazione nat, rdr, e binat possono applicare tag a pacchetti usando la keyword tag.
pass out on $ext_if tagged INT_NET keep state
I pacchetti in uscita sulla $ext_if devono essere contrassegnati con la tag INT_NET per avere corrispondenza con la regola precedente. Corrispondenze inverse si possono anche avere usando l'operatore !:
pass out on $ext_if ! tagged WIFI_NET keep state
Le regole di traslazione (nat/rdr/binat) possono anche usare la keyword tagged per avere corrispondenza di pacchetti.
Da notare che la policy copre tutto il traffico che sarà fatto passare attraverso il firewall. Il parametro tra parentesi indica il tag utilizzato per quella policy.
Regole di filtraggio e traslazione ora hanno bisogno di essere scritte per classificare i pacchetti nella policy.
rdr on $ext_if proto tcp from <spamd> to port smtp \
tag SPAMD -> 127.0.0.1 port 8025
nat on $ext_if tag LAN_INET_NAT tagged LAN_INET -> ($ext_if)
block all
pass in on $int_if from $int_net tag LAN_INET keep state
pass in on $int_if from $int_net to $dmz_net tag LAN_DMZ keep state
pass in on $ext_if proto tcp to $www_server port 80 tag INET_DMZ keep state
Ora le regole che caratterizzano la policy sono definite.
pass in quick on $ext_if tagged SPAMD keep state
pass out quick on $ext_if tagged LAN_INET_NAT keep state
pass out quick on $dmz_if tagged LAN_DMZ keep state
pass out quick on $dmz_if tagged INET_DMZ keep state
Ora che tutte le regole sono configurate, i cambi possono avvenire modificando le regole di classificazione. Per esempio, se un server POP3/SMTP viene aggiunto alla DMZ, sarà necessario aggiungere regole di classificazione per il traffico POP3 e SMTP, come le seguenti:
mail_server = "192.168.0.10"
...
pass in on $ext_if proto tcp to $mail_server port { smtp, pop3 } \
tag INET_DMZ keep state
Il traffico Email ora sarà fatto passare dalla policy INET_DMZ.
Il set di regole completo sarà:
# macros
int_if = "dc0"
dmz_if = "dc1"
ext_if = "ep0"
int_net = "10.0.0.0/24"
dmz_net = "192.168.0.0/24"
www_server = "192.168.0.5"
mail_server = "192.168.0.10"
table <spamd> persist file "/etc/spammers"
# classificazione -- classifica i pacchetti in base alla policy di
# firewall definita.
rdr on $ext_if proto tcp from <spamd> to port smtp \
tag SPAMD -> 127.0.0.1 port 8025
nat on $ext_if tag LAN_INET_NAT tagged LAN_INET -> ($ext_if)
block all
pass in on $int_if from $int_net tag LAN_INET keep state
pass in on $int_if from $int_net to $dmz_net tag LAN_DMZ keep state
pass in on $ext_if proto tcp to $www_server port 80 tag INET_DMZ keep state
pass in on $ext_if proto tcp to $mail_server port { smtp, pop3 } \
tag INET_DMZ keep state
# rafforzamento della policy -- pass/block basata sulla policy di
# firewall definita.
pass in quick on $ext_if tagged SPAMD keep state
pass out quick on $ext_if tagged LAN_INET_NAT keep state
pass out quick on $dmz_if tagged LAN_DMZ keep state
pass out quick on $dmz_if tagged INET_DMZ keep state
|
# brconfig bridge0 rule pass in on fxp0 src 0:de:ad:be:ef:0 \
tag USER1
E quindi in pf.conf:
pass in on fxp0 tagged USER1
[Precedente: Pool di indirizzi e bilanciamento del carico] [Indice] [Successivo: Logging]