]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - etc/rc.firewall6
Remove a comment which was past its shelf life.
[FreeBSD/FreeBSD.git] / etc / rc.firewall6
1 ############
2 # Setup system for IPv6 firewall service.
3 # $FreeBSD$
4
5 # Suck in the configuration variables.
6 if [ -z "${source_rc_confs_defined}" ]; then
7         if [ -r /etc/defaults/rc.conf ]; then
8                 . /etc/defaults/rc.conf
9                 source_rc_confs
10         elif [ -r /etc/rc.conf ]; then
11                 . /etc/rc.conf
12         fi
13 fi
14
15 ############
16 # Define the firewall type in /etc/rc.conf.  Valid values are:
17 #   open     - will allow anyone in
18 #   client   - will try to protect just this machine
19 #   simple   - will try to protect a whole network
20 #   closed   - totally disables IP services except via lo0 interface
21 #   UNKNOWN  - disables the loading of firewall rules.
22 #   filename - will load the rules in the given filename (full path required)
23 #
24 # For ``client'' and ``simple'' the entries below should be customized
25 # appropriately.
26
27 ############
28 #
29 # If you don't know enough about packet filtering, we suggest that you
30 # take time to read this book:
31 #
32 #       Building Internet Firewalls, 2nd Edition
33 #       Brent Chapman and Elizabeth Zwicky
34 #
35 #       O'Reilly & Associates, Inc
36 #       ISBN 1-56592-871-7
37 #       http://www.ora.com/
38 #       http://www.oreilly.com/catalog/fire2/
39 #
40 # For a more advanced treatment of Internet Security read:
41 #
42 #       Firewalls & Internet Security
43 #       Repelling the wily hacker
44 #       William R. Cheswick, Steven M. Bellowin
45 #
46 #       Addison-Wesley
47 #       ISBN 0-201-63357-4
48 #       http://www.awl.com/
49 #       http://www.awlonline.com/product/0%2C2627%2C0201633574%2C00.html
50 #
51
52 if [ -n "${1}" ]; then
53         ipv6_firewall_type="${1}"
54 fi
55
56 ############
57 # Set quiet mode if requested
58 #
59 case ${ipv6_firewall_quiet} in
60 [Yy][Ee][Ss])
61         fw6cmd="/sbin/ip6fw -q"
62         ;;
63 *)
64         fw6cmd="/sbin/ip6fw"
65         ;;
66 esac
67
68 ############
69 # Flush out the list before we begin.
70 #
71 ${fw6cmd} -f flush
72
73 ############
74 # If you just configured ipfw in the kernel as a tool to solve network
75 # problems or you just want to disallow some particular kinds of traffic
76 # then you will want to change the default policy to open.  You can also
77 # do this as your only action by setting the ipv6_firewall_type to ``open''.
78 #
79 # ${fw6cmd} add 65000 pass all from any to any
80
81 ############
82 # Only in rare cases do you want to change these rules
83 #
84 ${fw6cmd} add 100 pass all from any to any via lo0
85 #
86 # ND
87 #
88 # DAD
89 ${fw6cmd} add pass ipv6-icmp from ff02::/16 to ::
90 ${fw6cmd} add pass ipv6-icmp from :: to ff02::/16
91 # RS, RA, NS, NA, redirect...
92 ${fw6cmd} add pass ipv6-icmp from fe80::/10 to fe80::/10
93 ${fw6cmd} add pass ipv6-icmp from fe80::/10 to ff02::/16
94
95
96 # Prototype setups.
97 #
98 case ${ipv6_firewall_type} in
99 [Oo][Pp][Ee][Nn])
100         ${fw6cmd} add 65000 pass all from any to any
101         ;;
102
103 [Cc][Ll][Ii][Ee][Nn][Tt])
104         ############
105         # This is a prototype setup that will protect your system somewhat
106         # against people from outside your own network.
107         ############
108
109         # set these to your network and prefixlen and ip
110         #
111         # This needs more work
112         #
113         net="3ffe:505:2:1::"
114         prefixlen="64"
115         ip="3ffe:505:2:1::1"
116
117         # Allow any traffic to or from my own net.
118         ${fw6cmd} add pass all from ${ip} to ${net}/${prefixlen}
119         ${fw6cmd} add pass all from ${net}/${prefixlen} to ${ip}
120
121         # Allow TCP through if setup succeeded
122         ${fw6cmd} add pass tcp from any to any established
123
124         # Allow IP fragments to pass through
125         ${fw6cmd} add pass all from any to any frag
126
127         # Allow setup of incoming email
128         ${fw6cmd} add pass tcp from any to ${ip} 25 setup
129
130         # Allow setup of outgoing TCP connections only
131         ${fw6cmd} add pass tcp from ${ip} to any setup
132
133         # Disallow setup of all other TCP connections
134         ${fw6cmd} add deny tcp from any to any setup
135
136         # Allow DNS queries out in the world
137         ${fw6cmd} add pass udp from any 53 to ${ip}
138         ${fw6cmd} add pass udp from ${ip} to any 53
139
140         # Allow NTP queries out in the world
141         ${fw6cmd} add pass udp from any 123 to ${ip}
142         ${fw6cmd} add pass udp from ${ip} to any 123
143
144         # Everything else is denied by default, unless the
145         # IPFIREWALL_DEFAULT_TO_ACCEPT option is set in your kernel
146         # config file.
147         ;;
148
149 [Ss][Ii][Mm][Pp][Ll][Ee])
150         ############
151         # This is a prototype setup for a simple firewall.  Configure this
152         # machine as a named server and ntp server, and point all the machines
153         # on the inside at this machine for those services.
154         ############
155
156         # set these to your outside interface network and prefixlen and ip
157         oif="ed0"
158         onet="3ffe:505:2:1::"
159         oprefixlen="64"
160         oip="3ffe:505:2:1::1"
161
162         # set these to your inside interface network and prefixlen and ip
163         iif="ed1"
164         inet="3ffe:505:2:2::"
165         iprefixlen="64"
166         iip="3ffe:505:2:2::1"
167
168         # Stop spoofing
169         ${fw6cmd} add deny all from ${inet}/${iprefixlen} to any in via ${oif}
170         ${fw6cmd} add deny all from ${onet}/${oprefixlen} to any in via ${iif}
171
172         # Stop site-local on the outside interface
173         ${fw6cmd} add deny all from ff02::/16 to any via ${oif}
174         ${fw6cmd} add deny all from any to ff02::/16 via ${oif}
175
176         # Disallow "internal" addresses to appear on the wire.
177         ${fw6cmd} add deny all from ::ffff:0.0.0.0/96 to any via ${oif}
178         ${fw6cmd} add deny all from any to ::ffff:0.0.0.0/96 via ${oif}
179
180         # Disallow packets to malicious IPv4 compatible prefix.
181         ${fw6cmd} add deny all from ::224.0.0.0/100 to any via ${oif}
182         ${fw6cmd} add deny all from any to ::224.0.0.0/100 via ${oif}
183         ${fw6cmd} add deny all from ::127.0.0.0/104 to any via ${oif}
184         ${fw6cmd} add deny all from any to ::127.0.0.0/104 via ${oif}
185         ${fw6cmd} add deny all from ::0.0.0.0/104 to any via ${oif}
186         ${fw6cmd} add deny all from any to ::0.0.0.0/104 via ${oif}
187         ${fw6cmd} add deny all from ::255.0.0.0/104 to any via ${oif}
188         ${fw6cmd} add deny all from any to ::255.0.0.0/104 via ${oif}
189
190         ${fw6cmd} add deny all from ::0.0.0.0/96 to any via ${oif}
191         ${fw6cmd} add deny all from any to ::0.0.0.0/96 via ${oif}
192
193         # Disallow packets to malicious 6to4 prefix.
194         ${fw6cmd} add deny all from 2002:e000::/20 to any via ${oif}
195         ${fw6cmd} add deny all from any to 2002:e000::/20 via ${oif}
196         ${fw6cmd} add deny all from 2002:7f00::/24 to any via ${oif}
197         ${fw6cmd} add deny all from any to 2002:7f00::/24 via ${oif}
198         ${fw6cmd} add deny all from 2002:0000::/24 to any via ${oif}
199         ${fw6cmd} add deny all from any to 2002:0000::/24 via ${oif}
200         ${fw6cmd} add deny all from 2002:ff00::/24 to any via ${oif}
201         ${fw6cmd} add deny all from any to 2002:ff00::/24 via ${oif}
202
203         ${fw6cmd} add deny all from 2002:0a00::/24 to any via ${oif}
204         ${fw6cmd} add deny all from any to 2002:0a00::/24 via ${oif}
205         ${fw6cmd} add deny all from 2002:ac10::/28 to any via ${oif}
206         ${fw6cmd} add deny all from any to 2002:ac10::/28 via ${oif}
207         ${fw6cmd} add deny all from 2002:c0a8::/32 to any via ${oif}
208         ${fw6cmd} add deny all from any to 2002:c0a8::/32 via ${oif}
209
210         ${fw6cmd} add deny all from ff05::/32 to any via ${oif}
211         ${fw6cmd} add deny all from any to ff05::/32 via ${oif}
212
213         # Allow TCP through if setup succeeded
214         ${fw6cmd} add pass tcp from any to any established
215
216         # Allow IP fragments to pass through
217         ${fw6cmd} add pass all from any to any frag
218
219         # Allow setup of incoming email
220         ${fw6cmd} add pass tcp from any to ${oip} 25 setup
221
222         # Allow access to our DNS
223         ${fw6cmd} add pass tcp from any to ${oip} 53 setup
224         ${fw6cmd} add pass udp from any to ${oip} 53
225         ${fw6cmd} add pass udp from ${oip} 53 to any
226
227         # Allow access to our WWW
228         ${fw6cmd} add pass tcp from any to ${oip} 80 setup
229
230         # Reject&Log all setup of incoming connections from the outside
231         ${fw6cmd} add deny log tcp from any to any in via ${oif} setup
232
233         # Allow setup of any other TCP connection
234         ${fw6cmd} add pass tcp from any to any setup
235
236         # Allow DNS queries out in the world
237         ${fw6cmd} add pass udp from any 53 to ${oip}
238         ${fw6cmd} add pass udp from ${oip} to any 53
239
240         # Allow NTP queries out in the world
241         ${fw6cmd} add pass udp from any 123 to ${oip}
242         ${fw6cmd} add pass udp from ${oip} to any 123
243
244         # RIPng
245         #${fw6cmd} add pass udp from fe80::/10 521 to ff02::9 521
246
247         # Everything else is denied by default, unless the
248         # IPFIREWALL_DEFAULT_TO_ACCEPT option is set in your kernel
249         # config file.
250         ;;
251
252 [Uu][Nn][Kk][Nn][Oo][Ww][Nn])
253         ;;
254 *)
255         if [ -r "${ipv6_firewall_type}" ]; then
256                 ${fw6cmd} ${ipv6_firewall_flags} ${ipv6_firewall_type}
257         fi
258         ;;
259 esac