[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Règles pf



Bonsoir,

Je possède une bécane munie de 3 ports Ethernet et un port wifi, sur
laquelle tourne pf et un fichier de règles peu restrictif puisqu'elles
ne bloquent que les paquets entrant sur la passerelle.
Avec l'arrivée du Wifi, j'ai donc cherché à couper les paquets en 4, et
utiliser des règles plus restrictives au niveau de mes interfaces
internes.
J'ai donc fait une version de pf.conf plus restrictive permettant de
gérer le trafic interface par interface.
Après avoir bataillé un petit moment, j'ai fini par obtenir un firewall
qui gère parfaitement mon trafic interne, mais ne me permet pas
d'accéder à Internet.
Je pense qu'il me manque quelques règles passantes entre l'interface
externe et les internes, j'ai essayé sans succès des règles du type :

pass in on $int_if inet proto tcp from $lan_local to $ext_if port
$tcp_lanlocal_vers_passerelle flags S/SA modulate state

Ci-joint mon fichier pf.conf débarrassé de la plupart des lignes non
concernées par le problème.

Si vous avez une idée ... 


#########################################################################################
#                                                                                       #
#                                 Regles de filtrage PF                                 #
#                                                                                       #
#                                        laser                                          #
#                                                                                       #
#                                      24/03/2005                                       #
#                                                                                       #
#########################################################################################

ext_if="sis0"
dmz_if="sis1"
int_if="sis2"
wi_if="wi0"
enc_if="enc0"

lan_dmz="{ 192.168.10.0/24 }"
lan_local="{ 192.168.20.0/24 }"
lan_wifi="{ 192.168.30.0/24 }"


#########################################################################################
#				Declaration des flux    				#
#########################################################################################

#########################################################
#			tcp				#
#########################################################
tcp_internet_vers_passerelle "{ ssh, www, smtp, domain }"

tcp_passerelle_vers_internet= "{ ssh, www, https, smtp, ntp, pop3, rsync, nntp, domain, 8080, 5999 }"
tcp_passerelle_vers_landmz= "{ ssh, smtp }"
tcp_passerelle_vers_lanlocal= "{ ssh }"
tcp_passerelle_vers_lanwifi= "{ ssh }"

tcp_landmz_vers_passerelle= "{ ssh, smtp, http, ntp, ftp, domain, 5999 }"
tcp_landmz_vers_lanlocal= "{ ssh }"
tcp_landmz_vers_lanwifi= "{ ssh }"

tcp_lanlocal_vers_passerelle= "{ ssh, http, https, ntp, pop3, rsync, nntp, domain, 8080 }"
tcp_lanlocal_vers_landmz= "{ ssh, smtp, pop3 }"
tcp_lanlocal_vers_lanwifi= "{ ssh }"

tcp_lanwifi_vers_passerelle= "{ ssh, http, https, smtp, ntp, pop3, nntp, domain, 5999 }"
tcp_lanwifi_vers_landmz= "{ ssh, smtp, pop3 }"
tcp_lanwifi_vers_lanlocal= "{ ssh }"

#########################################################
#			udp				#
#########################################################
udp_internet_vers_passerelle= "{ domain }"

udp_passerelle_vers_internet= "{ domain, ntp }"
udp_passerelle_vers_landmz= "{ }"
udp_passerelle_vers_lanlocal= "{ }"
udp_passerelle_vers_lanwifi= "{ isakmp }"

udp_landmz_vers_passerelle= "{ domain, ntp }"
udp_landmz_vers_lanlocal= "{ }"
udp_landmz_vers_lanwifi= "{ }"

udp_lanlocal_vers_passerelle= "{ domain, ntp }"
udp_lanlocal_vers_landmz= "{ }"
udp_lanlocal_vers_lanwifi= "{ }"

udp_lanwifi_vers_passerelle= "{ isakmp }"
udp_lanwifi_vers_landmz= "{ }"
udp_lanwifi_vers_lanlocal= "{ }"

############################################
#                Options                   #
############################################

set optimization aggressive
set block-policy return
set loginterface $ext_if

############################################
#           Fixe les fragments		   #
############################################
scrub in all

#########################################################################################
#                                                                                       #
#                                  Traffic shapping                                     #
#                                                                                       #
#########################################################################################

# Regles AltQ
# altq on ext_if cbq 5633Kb

#########################################################################################
#                                                                                       #
#                                         NAT                                           #
#                                                                                       #
#########################################################################################

# NAT entre interface externe et interne
nat on $ext_if from !($ext_if) -> ($ext_if:0)
# Redirection du flux ftp vers le Proxy FTP transparent
rdr pass on $int_if proto tcp from $lan_local to any port ftp -> 127.0.0.1 port 8021
rdr pass on $dmz_if proto tcp from $lan_dmz to any port ftp -> 127.0.0.1 port 8021
rdr pass on $wi_if proto tcp from $lan_wifi to any port ftp -> 127.0.0.1 port 8021

#########################################################################################
#											#
#					Authpf						#
#											#
#########################################################################################

# nat-anchor authpf
# rdr-anchor authpf
# binat-anchor authpf

#########################################################################################
#                                                                                       #
#                                       Filtrage                                        #
#                                                                                       #
#########################################################################################

# On bloque toutes les interfaces par defaut
block return log
# On bloque les adresses ip non routables pour eviter le spoofing
antispoof log quick for $ext_if inet 

# On libere l'adresse loopback
#pass on lo0 all
pass out quick on lo0 all keep state
pass in quick on lo0 all keep state

                        #########################################
                        #                                       #
                        #	     Cas particuliers   	#
                        #                                       #
                        #########################################

# FTP-actif : on autorise une r�onse du serveur ftp contact�sur la plage de ports sp�ifi�
# au proxy ftp
#pass in on $ext_if inet proto tcp from any port ftp-data to $ext_if port 55000><57000 user proxy flags S/SA keep state
#pass out on $ext_if inet proto tcp from $ext_if to any port ftp-data flags S/AUPRFS modulate state

# FTP-passif : on autorise le traffic sortant vers le port ftp (21) et l'ouverture d'un port >1024
# pour contacter le serveur ftp distant
pass out on $ext_if inet proto tcp from $ext_if to any port ftp flags S/SA modulate state
pass out on $ext_if inet proto tcp from $ext_if to any port 55000><57000 flags S/SA modulate state

                        
			#########################################
                        #                                       #
                        #    Traffic entrant depuis Internet    #
                        #                                       #
                        #########################################

# Requetes destinees aux services tournant sur la passerelle
pass in on $ext_if inet proto tcp from any to $ext_if port $tcp_internet_vers_passerelle flags S/SA modulate state
pass in on $ext_if inet proto udp from any to $ext_if port $udp_internet_vers_passerelle keep state
pass in on $ext_if inet proto icmp from any to $ext_if icmp-type {echorep, echoreq, timex, unreach }

			#########################################
                        #                                       #
                        #     Traffic sortant vers Internet     #
                        #                                       #
                        #########################################
# Depuis la passerelle
pass out on $ext_if inet proto tcp from $ext_if to any port $tcp_passerelle_vers_internet flags S/SA modulate state
pass out on $ext_if inet proto udp from $ext_if to any port $udp_passerelle_vers_internet keep state
pass out on $ext_if inet proto icmp from any to any


                        #########################################
                        #                                       #
                        #	     Traffic interne		#
                        #                                       #
                        #########################################

# lan_dmz/passerelle
pass in on $dmz_if inet proto tcp from $lan_dmz to $dmz_if port $tcp_landmz_vers_passerelle flags S/SA modulate state
pass in on $dmz_if inet proto udp from $lan_dmz to $dmz_if port $udp_landmz_vers_passerelle keep state
pass out on $dmz_if inet proto tcp from $dmz_if to $lan_dmz port $tcp_passerelle_vers_landmz flags S/SA modulate state
pass out on $dmz_if inet proto udp from $dmz_if to $lan_dmz port $udp_passerelle_vers_landmz keep state
# lan_dmz vers lan_local
pass in on $dmz_if inet proto tcp from $lan_dmz to $lan_local port $tcp_landmz_vers_lanlocal flags S/SA modulate state
#pass in on $dmz_if inet proto udp from $lan_dmz to $lan_local port $udp_landmz_vers_lanlocal keep state
pass out on $dmz_if inet proto tcp from $lan_local to $lan_dmz port $tcp_lanlocal_vers_landmz flags S/SA modulate state
#pass out on $dmz_if inet proto udp from $lan_local to $lan_dmz port $udp_lanlocal_vers_landmz keep state

# lan_dmz vers lan_wifi
pass in on $dmz_if inet proto tcp from $lan_dmz to $lan_wifi port $tcp_landmz_vers_lanwifi flags S/SA modulate state
#pass in on $dmz_if inet proto udp from $lan_dmz to $lan_wifi port $udp_landmz_vers_lanwifi keep state
pass out on $dmz_if inet proto tcp from $lan_wifi to $lan_dmz port $tcp_lanwifi_vers_landmz flags S/SA modulate state
#pass out on $dmz_if inet proto udp from $lan_wifi to $lan_dmz port $udp_lanwifi_vers_landmz keep state

# lan_local vers passerelle
pass in on $int_if inet proto tcp from $lan_local to $int_if port $tcp_lanlocal_vers_passerelle flags S/SA modulate state
pass in on $int_if inet proto udp from $lan_local to $int_if port $udp_lanlocal_vers_passerelle keep state
pass out on $int_if inet proto tcp from $int_if to $lan_local port $tcp_passerelle_vers_lanlocal flags S/SA modulate state
pass out on $int_if inet proto udp from $int_if to $lan_local port $udp_passerelle_vers_lanlocal keep state

# lan_local vers lan_dmz
pass in on $int_if inet proto tcp from $lan_local to $lan_dmz port $tcp_lanlocal_vers_landmz flags S/SA modulate state
#pass in on $int_if inet proto udp from $lan_local to $lan_dmz port $udp_lanlocal_vers_landmz keep state
pass out on $int_if inet proto tcp from $lan_dmz to $lan_local port $tcp_landmz_vers_lanlocal flags S/SA modulate state
#pass out on $int_if inet proto udp from $lan_dmz to $lan_local port $udp_landmz_vers_lanlocal keep state

# lan_local vers lan_wifi
pass in on $int_if inet proto tcp from $lan_local to $lan_wifi port $tcp_lanlocal_vers_lanwifi flags S/SA modulate state
#pass in on $int_if inet proto udp from $lan_local to $lan_wifi port $udp_lanlocal_vers_lanwifi keep state
pass out on $int_if inet proto tcp from $lan_wifi to $lan_local port $tcp_lanwifi_vers_lanlocal flags S/SA modulate state
#pass out on $int_if inet proto udp from $lan_wifi to $lan_local port $udp_lanwifi_vers_lanlocal keep state

# lan_wifi vers passerelle
pass in on $wi_if inet proto tcp from $lan_wifi to $wi_if port $tcp_lanwifi_vers_passerelle flags S/SA modulate state
pass in on $wi_if inet proto udp from $lan_wifi to $wi_if port $udp_lanwifi_vers_passerelle keep state
pass out on $wi_if inet proto tcp from $wi_if to $lan_wifi port $tcp_passerelle_vers_lanwifi flags S/SA modulate state
pass out on $wi_if inet proto udp from $wi_if to $lan_wifi port $udp_passerelle_vers_lanwifi keep state

# lan_wifi vers lan_dmz
pass in on $wi_if inet proto tcp from $lan_wifi to $lan_dmz port $tcp_lanwifi_vers_landmz flags S/SA modulate state
#pass in on $wi_if inet proto udp from $lan_wifi to $lan_dmz port $udp_lanwifi_vers_landmz keep state
pass out on $wi_if inet proto tcp from $lan_dmz to $lan_wifi port $tcp_landmz_vers_lanwifi flags S/SA modulate state
#pass out on $wi_if inet proto udp from $lan_dmz to $lan_wifi port $udp_landmz_vers_lanwifi keep state

# lan_wifi vers lan_local
pass in on $wi_if inet proto tcp from $lan_wifi to $lan_local port $tcp_lanwifi_vers_lanlocal flags S/SA modulate state
#pass in on $wi_if inet proto udp from $lan_wifi to $lan_local port $udp_lanwifi_vers_lanlocal keep state
pass out on $wi_if inet proto tcp from $lan_local to $lan_wifi port $tcp_lanlocal_vers_lanwifi flags S/SA modulate state
#pass out on $wi_if inet proto udp from $lan_local to $lan_wifi port $udp_lanlocal_vers_lanwifi keep state