Firewall pour station connectée à Internet en PPP : Ipfw
Ipfw (firewall à filtrage de paquet avec conservation d'Etat - statefull inspection)
Ipfw est un outil permettant de configurer les règles des firewalls présents sous diverses architectures (certains Bsd entre autres).
Quelques rappels :
Scripts présentés :
Les deux scripts présentés ont les caractéristiques suivantes :
Ils pourraient par exemple être utilisés sous Mac OS X.
Exemples de logs :
Nov 7 19:42:18 HOST mach_kernel: ipfw: 65002 Deny UDP x.x.x.x:1038 p.p.p.a:137 in via ppp0
Nov 7 19:42:27 HOST mach_kernel: ipfw: 65004 Deny TCP x.x.x.x:4179 p.p.p.a:80 in via ppp0
Ipfw_ppp_down.sh :
#!/bin/sh
### VARIABLES
IPFW="/sbin/ipfw -q"
### BEGIN
${IPFW} -f flush
echo "$0 done"
Ipfw_ppp_up.sh :
#!/bin/sh
### VARIABLES
IPFW="/sbin/ipfw -q"
# Source system functions
. /etc/rc.common
# Turn on logging
if [ `/usr/sbin/sysctl -n net.inet.ip.fw.verbose` == 0 ] ; then
/usr/sbin/sysctl -w net.inet.ip.fw.verbose=1
fi
### BEGIN
# Flush rules
${IPFW} -f flush
### LOOPBACK, STATEFULL AND REMOTE MANAGEMENT
# Allow whatever on loopback
${IPFW} add 01000 allow ip from any to any via lo0
# Allow fragments
${IPFW} add 02000 allow ip from any to any frag
# Allow established connections
${IPFW} add 02001 allow tcp from any to any established
### ALLOW THESE TCP CONNECTIONS
# Allow Syn TCP to HTTP and HTTPS servers
${IPFW} add 07000 allow tcp from any 1024- to any 80 setup out
${IPFW} add 07001 allow tcp from any 1024- to any 443 setup out
# Allow Syn TCP to POP/SMTP Servers
${IPFW} add 07002 allow tcp from any 1024- to any 110 setup out
${IPFW} add 07003 allow tcp from any 1024- to any 25 setup out
# Allow Syn TCP to SSH servers anywhere
${IPFW} add 07015 allow tcp from any 1024- to any 22 setup out
### ALLOW THESE UDP CONNECTIONS
# Allow DNS Protocol to DNS Servers
${IPFW} add 08000 allow udp from any 1024- to any 53 out
${IPFW} add 08001 allow udp from any 53 to any 1024- in
### ALLOW THESE ICMP CONNECTIONS
# Allow that kind of ICMP packets
# Note : ECHO REPL 0 / DEST UNREACH 3 / ECHO REQ 8 / TIME EXCEED 11
${IPFW} add 09000 allow icmp from any to any icmptype 8 out
${IPFW} add 09001 allow icmp from any to any icmptype 0,3,11 in
### AND LAST : LOG AND DENY
${IPFW} add 65000 deny log icmp from any to any in
${IPFW} add 65001 deny log icmp from any to any out
${IPFW} add 65002 deny log udp from any to any in
${IPFW} add 65003 deny log udp from any to any out
${IPFW} add 65004 deny log tcp from any to any in
${IPFW} add 65005 deny log tcp from any to any out
${IPFW} add 65006 deny log ip from any to any in
${IPFW} add 65007 deny log ip from any to any out
# This rule is set on default Mac Os X ipfw
${IPFW} zero 65535
echo "$0 done"
Simon Castro
Maj le 27 novembre 2002