Bonjour à tous,
je me suis décidé récemment à utiliser mon NAS comme firewall / routeur pour remplacer ma freebox.
On m’a aidé pour la configuration du réseau chez moi, la configuration des adresses IP des 2 cartes réseau du NAS, et pour le choix de PF pour réaliser le filtrage / routage.
J’ai pas mal potassé la doc de PF, ainsi que 2/3 exemples que j’ai vu sur internet, mais je voulais avoir votre avis sur mon fichier pf.conf, avant de lancer le bouzin chez moi, et de tout planter
Tout d’abord, voici ce que je veux avoir (du très standard je pense):
Bloquer tout le traffic venant de l’extérieur par défaut, et l’enregistrer
Me permettre depuis internet de me connecter sur mon webserver (qui est la même machine que le NAS, 192.168.0.1) via les port 80 et 443
Me permettre depuis internet de me connecter sur le NAS en SSH (donc port 22)
Me permettre depuis internet de me connecter sur le switch (192.168.0.2) sur le port 80
Pouvoir depuis le réseau local accéder à internet
Je suis arrivé à ce résultat:
[quote]# Configuration file for PF
Declaration of network interfaces
ext_inf = « xl0 »
int_inf = « nfe0 »
loop_inf = « lo »
Declaration of ports which shouldn’t be logged
ports_not_logged = « { netbios-ssn, microsoft-ds, epmap, ms-sql-s } »
ICMP types allowed
icmp_types = « { echoreq } »
Declaration of ports to redirect to the NAS
ports_to_webserver = « { 80, 443 } »
ports_to_nas = « { 22 } »
all_ports_to_nas = {" ports_to_nas + ports_to_webserver "}
Declaration of ports to redirect to the switch
ports_to_switch = « { 8080 } »
Declaration of hosts on the local network
nas = « 192.168.0.1 »
switch = « 192.168.0.2 »
desktop = « 192.168.0.10 »
laptop = « 192.168.0.11 »
Default answer for « block » filter rules
set block-policy return
Don’t work on the loopback interface
set skip on lo
Normalize ingoing packets
scrub in
NAT on local network
nat on $ext_inf from $int_inf to any → $ext_inf
Redirect communications to NAS from the external interface
rdr on $ext_inf proto tcp from any to any port $all_ports_to_nas → $nas
Redirect communications to the switch from the external interface
rdr on $ext_inf proto tcp from any to any port $ports_to_switch → $switch
Default block all packets coming from the outside
block in on $ext_inf log all
block in on $ext_inf inet proto tcp from any to any port $ports_not_logged
Filter all ingoing traffic
pass out keep state
Don’t filter packets on the internal interface
pass quick on $int_inf
Protection against address spoofing
antispoof quick for { lo $int_inf }
Open ports used by the NAS
pass in on $ext_inf inet proto tcp from any to $ext_if port $ports_to_nas flags S/SA keep state
Open ports used by the Webserver
pass in on $ext_inf proto tcp from any to $nas port $ports_to_nas flags S/SA synproxy state
Allow ICMP traffic
pass in on $ext_inf inet proto icmp all icmp-type $icmp_types[/quote]
Est-ce que ça vous semble OK? Si ce n’est pas le cas, qu’est-ce que vous conseilleriez de changer?
Merci d’avance
Mike