Another update. Clarify that a shared spinlock can be acquired while holding
[dragonfly.git] / share / examples / ipfilter / firewall.2
1 # $FreeBSD: src/share/examples/ipfilter/firewall.2,v 1.1.2.2 2002/12/29 16:35:38 schweikh Exp $
2 # $DragonFly: src/share/examples/ipfilter/firewall.2,v 1.2 2003/06/17 04:36:57 dillon Exp $
3 #
4 #  This is an example of a fairly heavy firewall used to keep everyone
5 #  out of a particular network while still allowing people within that
6 #  network to get outside.
7 #
8 #  The example assumes it is running on a gateway with interface ppp0
9 #  attached to the outside world, and interface ed0 attached to
10 #  network 192.168.4.0 which needs to be protected.
11 #
12 #
13 #  Pass any packets not explicitly mentioned by subsequent rules
14 #
15 pass out from any to any
16 pass in from any to any
17 #
18 #  Block any inherently bad packets coming in from the outside world.
19 #  These include ICMP redirect packets, IP fragments so short the
20 #  filtering rules won't be able to examine the whole UDP/TCP header,
21 #  and anything with IP options.
22 #
23 block in log quick on ppp0 proto icmp from any to any icmp-type redir
24 block in log quick on ppp0 proto tcp/udp all with short
25 block in log quick on ppp0 from any to any with ipopts
26 #
27 #  Block any IP spoofing attempts.  (Packets "from" our network
28 #  shouldn't be coming in from outside).
29 #
30 block in log quick on ppp0 from 192.168.4.0/24 to any
31 block in log quick on ppp0 from localhost to any
32 block in log quick on ppp0 from 0.0.0.0/32 to any
33 block in log quick on ppp0 from 255.255.255.255/32 to any
34 #
35 #  Block all incoming UDP traffic except talk and DNS traffic.  NFS
36 #  and portmap are special-cased and logged.
37 #
38 block in on ppp0 proto udp from any to any
39 block in log on ppp0 proto udp from any to any port = sunrpc
40 block in log on ppp0 proto udp from any to any port = 2049
41 pass in on ppp0 proto udp from any to any port = domain
42 pass in on ppp0 proto udp from any to any port = talk
43 pass in on ppp0 proto udp from any to any port = ntalk
44 #
45 #  Block all incoming TCP traffic connections to known services,
46 #  returning a connection reset so things like ident don't take
47 #  forever timing out.  Don't log ident (auth port) as it's so common.
48 #
49 block return-rst in log on ppp0 proto tcp from any to any flags S/SA
50 block return-rst in on ppp0 proto tcp from any to any port = auth flags S/SA
51 #
52 #  Allow incoming TCP connections to ports between 1024 and 5000, as
53 #  these don't have daemons listening but are used by outgoing
54 #  services like ftp and talk.  For slightly more obscurity (though
55 #  not much more security), the second commented out rule can chosen
56 #  instead.
57 #
58 pass in on ppp0 proto tcp from any to any port 1024 >< 5000
59 #pass in on ppp0 proto tcp from any port = ftp-data to any port 1024 >< 5000
60 #
61 #  Now allow various incoming TCP connections to particular hosts, TCP
62 #  to the main nameserver so secondaries can do zone transfers, SMTP
63 #  to the mail host, www to the web server (which really should be
64 #  outside the firewall if you care about security), and ssh to a
65 #  hypothetical machine caled 'gatekeeper' that can be used to gain
66 #  access to the protected network from the outside world.
67 #
68 pass in on ppp0 proto tcp from any to ns1 port = domain
69 pass in on ppp0 proto tcp from any to mail port = smtp
70 pass in on ppp0 proto tcp from any to www port = www
71 pass in on ppp0 proto tcp from any to gatekeeper port = ssh