rc.firewall revision 17671
1############
2# Setup system for firewall service.
3# $Id: rc.firewall,v 1.4 1996/08/14 14:41:58 jkh Exp $
4
5############
6#
7# >>Warning<<
8# This file is not very old yet, and have been put together without much
9# testing of the contents.
10
11# Set this to be the type of firewall you want:  open, client, simple or NONE.
12# ``open'' will allow anyone in, ``client'' will try to protect just one
13# machine and ``simple'' will try to protect a whole network (entries should
14# be customized appropriately below).  To let no one in, use NONE.
15
16firewall_type=NONE
17
18
19############
20#
21# If you don't know enough about packet filtering, we suggest that you
22# take time to read this book:
23#
24#	Building Internet Firewalls
25#	Brent Chapman and Elizabeth Zwicky
26#
27#	O'Reilly & Associates, Inc
28#	ISBN 1-56592-124-0
29#
30# For a more advanced treatment of Internet Security read:
31#
32#	Firewalls & Internet Security
33#	Repelling the wily hacker
34#	William R. Cheswick, Steven M. Bellowin
35#
36#	Addison-Wesley
37#	ISBN 0-201-6337-4
38#
39
40############
41# Flush out the list before we begin.
42/sbin/ipfw flush
43
44############
45# If you just configured ipfw in the kernel as a tool to solve network
46# problems or you just want to disallow some particular kinds of traffic
47# they you will want to change the default policy to open.  You can also
48# do this as your only action by setting the firewall_type to ``open''.
49
50# /sbin/ipfw add 65000 pass all from any to any
51
52############
53# Only in rare cases do you want to change this rule
54/sbin/ipfw add 1000 pass all from 127.0.0.1 to 127.0.0.1
55
56
57# Prototype setups.
58if [ "${firewall_type}" = "open" ]; then
59
60	/sbin/ipfw add 65000 pass all from any to any
61
62elif [ "${firewall_type}" = "client" ]; then
63
64    ############
65    # This is a prototype setup that will protect your system somewhat against
66    # people from outside your own network.
67    ############
68
69    # set these to your network and netmask and ip
70    net="192.168.4.0"
71    mask="255.255.255.0"
72    ip="192.168.4.17"
73
74    # Allow any traffic to or from my own net.
75    /sbin/ipfw add pass all from ${ip} to ${net}:${mask}
76    /sbin/ipfw add pass all from ${net}:${mask} to ${ip}
77
78    # Allow TCP through if setup succeeded
79    /sbin/ipfw add pass tcp from any to any established
80
81    # Allow setup of incoming email 
82    /sbin/ipfw add pass tcp from any to ${ip} 25 setup
83
84    # Allow setup of outgoing TCP connections only
85    /sbin/ipfw add pass tcp from ${ip} to any setup
86
87    # Disallow setup of all other TCP connections
88    /sbin/ipfw add deny tcp from any to any setup
89
90    # Allow DNS queries out in the world
91    /sbin/ipfw add pass udp from any 53 to ${ip}
92    /sbin/ipfw add pass udp from ${ip} to any 53
93
94    # Allow NTP queries out in the world
95    /sbin/ipfw add pass udp from any 123 to ${ip}
96    /sbin/ipfw add pass udp from ${ip} to any 123
97
98    # Everyting else is denied as default.
99
100elif [ "${firewall_type}" = "simple" ]; then
101
102    ############
103    # This is a prototype setup for a simple firewall.  Configure this machine 
104    # as a named server and ntp server, and point all the machines on the inside
105    # at this machine for those services.
106    ############
107
108    # set these to your outside interface network and netmask and ip
109    oif="ed0"
110    onet="192.168.4.0"
111    omask="255.255.255.0"
112    oip="192.168.4.17"
113
114    # set these to your inside interface network and netmask and ip
115    iif="ed1"
116    inet="192.168.3.0"
117    imask="255.255.255.0"
118    iip="192.168.3.17"
119
120    # Stop spoofing
121    /sbin/ipfw add deny all from ${inet}:${imask} to any in via ${oif}
122    /sbin/ipfw add deny all from ${onet}:${omask} to any in via ${iif}
123
124    # Stop RFC1918 nets on the outside interface
125    /sbin/ipfw add deny all from 192.168.0.0:255.255.0.0 to any via ${oif}
126    /sbin/ipfw add deny all from 172.16.0.0:255.240.0.0 to any via ${oif}
127    /sbin/ipfw add deny all from 10.0.0.0:255.0.0.0 to any via ${oif}
128
129    # Allow TCP through if setup succeeded
130    /sbin/ipfw add pass tcp from any to any established
131
132    # Allow setup of incoming email 
133    /sbin/ipfw add pass tcp from any to ${oip} 25 setup
134
135    # Allow access to our DNS
136    /sbin/ipfw add pass tcp from any to ${oip} 53 setup
137
138    # Allow access to our WWW
139    /sbin/ipfw add pass tcp from any to ${oip} 80 setup
140
141    # Reject&Log all setup of incoming connections from the outside
142    /sbin/ipfw add deny log tcp from any to any in via ${oif} setup
143
144    # Allow setup of any other TCP connection
145    /sbin/ipfw add pass tcp from any to any setup
146
147    # Allow DNS queries out in the world
148    /sbin/ipfw add pass udp from any 53 to ${oip}
149    /sbin/ipfw add pass udp from ${oip} to any 53
150
151    # Allow NTP queries out in the world
152    /sbin/ipfw add pass udp from any 123 to ${oip}
153    /sbin/ipfw add pass udp from ${oip} to any 123
154
155    # Everyting else is denied as default.
156fi
157
158