

Autour de LDAP
Awstats
Backup HP COLORADO 5G
Compatibilit� Linux
Configuration NFS
Configuration ZSH
Configuration de FreeBSD
Connexion ADSL PPPOE
IPFILTER
Installation PXE
Installation d'un DNS
Installation d'un Squirrelmail
Installation de Apache SSL
Installation de FreeBSD
Installation de GRUB
Installation de MailScanner
Installation de PostgreSQL
Jail sous FreeBSD
Mise a jour de votre FreeBSD
Serveur CVS
Serveur DHCPd
Serveur IRCd
Serveur NTPd
Serveur ProFTPd
Serveur at home
Utilisation simple de CVS
X11: interface graphique




Et aussi ...
rockanjou.org
|
Firewall IPFILTER
SOMMAIRE :
1.Introduction
2.pr�-requis
3.Compilation du noyau
4.Configuration de la distribution
5.Configuration exemple d'IPFILTER
6.Commandes utiles
1.Introduction
FreeBSD g�re plusieurs firewalls.
Historiquement, le firewall de FreeBSD est IpFirewall, mais celui-ci tant � dispara�tre au profis de celui de OpenBSD (ancien, maintenant OpenBSD utilise PF).
IPFILTER est l'un des firewalls les plus robustes et s�r.
IPFILTER est un firewall qui permet de controler toutes les entr�es-sorties des
interfaces reseaux.
L'avantage par rapport a d'autres firewall tels que ifchains,
ipfw ... est qu'IPFILTER permet un meilleur controle des entr�es, independament des
sorties, et il permet en plus de faire du NAT.
Pour pouvoir utiliser IPFILTER, il y a plusieurs fichiers et parametres � modifier.
Nous allons voir ca par la suite dans cette page.
1.pr�-requis
Ici, on va consid�rer des cartes r�seau 3COM 3c905 Boomerang.
on leur allouera les ip 192.168.1.5 et 192.168.1.6 sur l'interface xl0 et xl1 ou xl1 est consid�r� comme interface externe en SNAT sur le routeur externe. (nomenclature BSD).
3.Compilation du noyau
Il faut ajouter les lignes suivantes dans le fichier de conf de votre noyau.
options PFIL_HOOKS
options IPFILTER
options IPFILTER_LOG
options IPFILTER_DEFAULT_BLOCK
options RANDOM_IP_ID
Une ligne utile pour le s�curit�, qui g�n�re des id de paquets IP de fa�on al�atoire :
options RANDOM_IP_ID
d�tail des param�tres
:
"options PFIL_HOOKS": Sans ce param�tre, vous aurez une erreur de compilation du noyau.
"options IPFILTER": on veux utiliser IPFILTER dans le noyau
"options IPFILTER_LOG": permet de faire un log des packet recu et/ou envoy�
"options IPFILTER_DEFAULT_BLOCK": par defaut: on bloque les communications
"options RANDOM_IP_ID": permet de generer des identifiants de packets al�atoire
On compile le noyau (v�rifiez que vos sources sont � jour :) )
make buildkernel KERNCONF=/usr/src/sys/i386/conf/MONKERN
make installkernel KERNCONF=/usr/src/sys/i386/conf/MONKERN
4.Configuration de la distribution
On ajoute dans le fichier de configuration de la distribution :
vi /etc/rc.conf
--
ipfilter_enable="YES"
ipfilter_flags=""
ipfilter_program="/sbin/ipf"
ipfilter_rules="/etc/ipf.rules"
# monitoring
ipmon_enable="YES" # les logs d'IPFILTER
ipmon_flags="-Dsvn"
#ipnat_enable="YES" # pas utiles, pour info
5.Configuration exemple d'IPFILTER
La configuration d'ipfilter se fait dans le fichier /etc/ipf.rules, ici on consid�rent :
vi /etc/ipf.rules
--
# on passe tout sur la boucle local
pass in quick on lo0 all
pass out quick on lo0 all
# on passe tout le traffic sur la patte interne
pass in quick on xl0 all
# on passe tout le traffic sortant
pass out quick proto tcp all keep state
pass out quick proto udp all keep state
# on bloque tout les paquets IP avec ipopts y conmpris lsrr et ssrr
block in quick all with ipopts
# on bloque les paquets fragment�s
block in quick all with frag
# on bloque les tentative de nmpa OS fingerprint
block in quick on xl1 proto tcp all flags FUP
block in log quick on xl1 proto tcp from any to any flags SF/SFRA
block in log quick on xl1 proto tcp from any to any flags /SFRA
# nmap outing sur interface externe et log
block in log quick on xl1 proto tcp all flags SF/SFRA
block in log quick on xl1proto tcp all flags /SFRA
block in log quick on xl1 proto tcp all flags F/SFRA
block in log quick on xl1 proto tcp all flags U/SFRAU
block in log quick on xl1 proto tcp all flags P
block in log quick on xl1 proto tcp from any to any flags FUP
block in log quick on xl1 proto tcp from any to any port = 111
# r�seau non routable sur l'interface externe
block in quick on xl1 from 255.255.255.255/32 to any
# block in quick on xl1 from 192.168.0.0/16 to any
block in quick on xl1 from 172.16.0.0/12 to any
block in quick on xl1 from 127.0.0.0/8 to any
block in quick on xl1 from 10.0.0.0/8 to any
block in quick on xl1 from 0.0.0.0/32 to any
# bloque les ICMP externe
block in quick on xl1 proto icmp from any to any icmp-type 0 keep state
block in quick on xl1 proto icmp from any to any icmp-type 3 keep state
block in quick on xl1 proto icmp from any to any icmp-type 8 keep state
block in quick on xl1 proto icmp from any to any icmp-type 11 keep state
pass in quick on xl0 proto icmp from any to any icmp-type 0 keep state
pass in quick on xl0 proto icmp from any to any icmp-type 3 keep state
pass in quick on xl0 proto icmp from any to any icmp-type 8 keep state
pass in quick on xl0 proto icmp from any to any icmp-type 11 keep state
pass out quick on xl0 proto icmp from any to any icmp-type 0 keep state
pass out quick on xl0 proto icmp from any to any icmp-type 3 keep state
pass out quick on xl0 proto icmp from any to any icmp-type 8 keep state
pass out quick on xl0 proto icmp from any to any icmp-type 11 keep state
# blacklist
block in quick on xl1 from 216.133.253.100 to any
block out quick on xl1 from any to 216.133.253.100
# on passe les services
pass in quick on xl1 proto tcp from any to any port = 22 keep state
pass in quick on xl1 proto tcp from any to any port = 25 keep state
pass in quick on xl1 proto tcp from any to any port = 21 keep state
pass in quick on xl1 proto tcp from any to any port = 443 keep state
pass in quick on xl1 proto tcp from any to any port = 80 keep state
# on bloque le reste
block in quick on xl1
6.Commandes utiles
Lancer le firewall :
root@machine[~]% ipf -Fa -f /etc/ipf.rules
Surveiller le firewall :
root@machine[~]% ipfstat -hio
Relancer le firewall :
root@machine[~]% /sbin/ipf -Fa -f /etc/ipf.rules
Statitique comme 'top' :
root@machine[~]% /sbin/ipfstat -t
Version d'IPFILTER :
root@machine[~]% /sbin/ipf -V
Romain GEORGES le 2003/04/13 |
|