xref: /onnv-gate/usr/src/cmd/ipf/examples/BASIC_2.FW (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!/sbin/ipf -f -
2*0Sstevel@tonic-gate#
3*0Sstevel@tonic-gate# SAMPLE: PERMISSIVE FILTER RULES
4*0Sstevel@tonic-gate#
5*0Sstevel@tonic-gate# THIS EXAMPLE IS WRITTEN FOR IP FILTER 3.3
6*0Sstevel@tonic-gate#
7*0Sstevel@tonic-gate# ppp0 - (external) PPP connection to ISP, address a.b.c.d/32
8*0Sstevel@tonic-gate#
9*0Sstevel@tonic-gate# ed0 - (internal) network interface, address w.x.y.z/32
10*0Sstevel@tonic-gate#
11*0Sstevel@tonic-gate# This file contains the basic rules needed to construct a firewall for the
12*0Sstevel@tonic-gate# above situation.
13*0Sstevel@tonic-gate#
14*0Sstevel@tonic-gate#-------------------------------------------------------
15*0Sstevel@tonic-gate# *Nasty* packets we don't want to allow near us at all!
16*0Sstevel@tonic-gate# short packets which are packets fragmented too short to be real.
17*0Sstevel@tonic-gateblock in log quick all with short
18*0Sstevel@tonic-gate#-------------------------------------------------------
19*0Sstevel@tonic-gate# Group setup.
20*0Sstevel@tonic-gate# ============
21*0Sstevel@tonic-gate# By default, block and log everything.  This maybe too much logging
22*0Sstevel@tonic-gate# (especially for ed0) and needs to be further refined.
23*0Sstevel@tonic-gate#
24*0Sstevel@tonic-gateblock in log on ppp0 all head 100
25*0Sstevel@tonic-gateblock out log on ppp0 all head 150
26*0Sstevel@tonic-gateblock in log on ed0 from w.x.y.z/24 to any head 200
27*0Sstevel@tonic-gateblock out log on ed0 all head 250
28*0Sstevel@tonic-gate#-------------------------------------------------------
29*0Sstevel@tonic-gate# Invalid Internet packets.
30*0Sstevel@tonic-gate# =========================
31*0Sstevel@tonic-gate#
32*0Sstevel@tonic-gate# Deny reserved addresses.
33*0Sstevel@tonic-gate#
34*0Sstevel@tonic-gateblock in log quick from 10.0.0.0/8 to any group 100
35*0Sstevel@tonic-gateblock in log quick from 192.168.0.0/16 to any group 100
36*0Sstevel@tonic-gateblock in log quick from 172.16.0.0/12 to any group 100
37*0Sstevel@tonic-gate#
38*0Sstevel@tonic-gate# Prevent IP spoofing.
39*0Sstevel@tonic-gate#
40*0Sstevel@tonic-gateblock in log quick from a.b.c.d/24 to any group 100
41*0Sstevel@tonic-gate#
42*0Sstevel@tonic-gate#-------------------------------------------------------
43*0Sstevel@tonic-gate# Localhost packets.
44*0Sstevel@tonic-gate# ==================
45*0Sstevel@tonic-gate# packets going in/out of network interfaces that aren't on the loopback
46*0Sstevel@tonic-gate# interface should *NOT* exist.
47*0Sstevel@tonic-gateblock in log quick from 127.0.0.0/8 to any group 100
48*0Sstevel@tonic-gateblock in log quick from any to 127.0.0.0/8 group 100
49*0Sstevel@tonic-gateblock in log quick from 127.0.0.0/8 to any group 200
50*0Sstevel@tonic-gateblock in log quick from any to 127.0.0.0/8 group 200
51*0Sstevel@tonic-gate# And of course, make sure the loopback allows packets to traverse it.
52*0Sstevel@tonic-gatepass in quick on lo0 all
53*0Sstevel@tonic-gatepass out quick on lo0 all
54*0Sstevel@tonic-gate#-------------------------------------------------------
55*0Sstevel@tonic-gate# Allow any communication between the inside network and the outside only.
56*0Sstevel@tonic-gate#
57*0Sstevel@tonic-gate# Allow all outgoing connections (SSH, TELNET, FTP, WWW, gopher, etc)
58*0Sstevel@tonic-gate#
59*0Sstevel@tonic-gatepass in log quick proto tcp all flags S/SA keep state group 200
60*0Sstevel@tonic-gate#
61*0Sstevel@tonic-gate# Support all UDP `connections' initiated from inside.
62*0Sstevel@tonic-gate#
63*0Sstevel@tonic-gate# Allow ping out
64*0Sstevel@tonic-gate#
65*0Sstevel@tonic-gatepass in log quick proto icmp all keep state group 200
66*0Sstevel@tonic-gate#-------------------------------------------------------
67*0Sstevel@tonic-gate# Log these:
68*0Sstevel@tonic-gate# ==========
69*0Sstevel@tonic-gate# * return RST packets for invalid SYN packets to help the other end close
70*0Sstevel@tonic-gateblock return-rst in log proto tcp from any to any flags S/SA group 100
71*0Sstevel@tonic-gate# * return ICMP error packets for invalid UDP packets
72*0Sstevel@tonic-gateblock return-icmp(net-unr) in proto udp all group 100
73