|
Line 0
Link Here
|
|
|
1 |
############ |
| 2 |
# Setup system for firewall service. |
| 3 |
# $FreeBSD$ |
| 4 |
|
| 5 |
# Suck in the configuration variables. |
| 6 |
if [ -r /etc/defaults/rc.conf ]; then |
| 7 |
. /etc/defaults/rc.conf |
| 8 |
elif [ -r /etc/rc.conf ]; then |
| 9 |
. /etc/rc.conf |
| 10 |
fi |
| 11 |
|
| 12 |
############ |
| 13 |
# Define the firewall type in /etc/rc.conf. Valid values are: |
| 14 |
# open - will allow anyone in |
| 15 |
# client - will try to protect just this machine |
| 16 |
# simple - will try to protect a whole network |
| 17 |
# closed - totally disables IP services except via lo0 interface |
| 18 |
# UNKNOWN - disables the loading of firewall rules. |
| 19 |
# filename - will load the rules in the given filename (full path required) |
| 20 |
# |
| 21 |
# For ``client'' and ``simple'' the entries below should be customized |
| 22 |
# appropriately. |
| 23 |
|
| 24 |
############ |
| 25 |
# |
| 26 |
# If you don't know enough about packet filtering, we suggest that you |
| 27 |
# take time to read this book: |
| 28 |
# |
| 29 |
# Building Internet Firewalls |
| 30 |
# Brent Chapman and Elizabeth Zwicky |
| 31 |
# |
| 32 |
# O'Reilly & Associates, Inc |
| 33 |
# ISBN 1-56592-124-0 |
| 34 |
# http://www.ora.com/ |
| 35 |
# |
| 36 |
# For a more advanced treatment of Internet Security read: |
| 37 |
# |
| 38 |
# Firewalls & Internet Security |
| 39 |
# Repelling the wily hacker |
| 40 |
# William R. Cheswick, Steven M. Bellowin |
| 41 |
# |
| 42 |
# Addison-Wesley |
| 43 |
# ISBN 0-201-6337-4 |
| 44 |
# http://www.awl.com/ |
| 45 |
# |
| 46 |
|
| 47 |
if [ -n "${1}" ]; then |
| 48 |
firewall6_type="${1}" |
| 49 |
fi |
| 50 |
|
| 51 |
############ |
| 52 |
# Set quiet mode if requested |
| 53 |
# |
| 54 |
case ${firewall6_quiet} in |
| 55 |
[Yy][Ee][Ss]) |
| 56 |
fw6cmd="/sbin/ip6fw -q" |
| 57 |
;; |
| 58 |
*) |
| 59 |
fw6cmd="/sbin/ip6fw" |
| 60 |
;; |
| 61 |
esac |
| 62 |
|
| 63 |
############ |
| 64 |
# Flush out the list before we begin. |
| 65 |
# |
| 66 |
${fw6cmd} -f flush |
| 67 |
|
| 68 |
############ |
| 69 |
# If you just configured ipfw in the kernel as a tool to solve network |
| 70 |
# problems or you just want to disallow some particular kinds of traffic |
| 71 |
# then you will want to change the default policy to open. You can also |
| 72 |
# do this as your only action by setting the firewall6_type to ``open''. |
| 73 |
# |
| 74 |
# ${fw6cmd} add 65000 pass all from any to any |
| 75 |
|
| 76 |
############ |
| 77 |
# Only in rare cases do you want to change these rules |
| 78 |
# |
| 79 |
${fw6cmd} add 100 pass all from any to any via lo0 |
| 80 |
|
| 81 |
|
| 82 |
# Prototype setups. |
| 83 |
# |
| 84 |
case ${firewall6_type} in |
| 85 |
[Oo][Pp][Ee][Nn]) |
| 86 |
${fw6cmd} add 65000 pass all from any to any |
| 87 |
;; |
| 88 |
|
| 89 |
[Cc][Ll][Ii][Ee][Nn][Tt]) |
| 90 |
############ |
| 91 |
# This is a prototype setup that will protect your system somewhat |
| 92 |
# against people from outside your own network. |
| 93 |
############ |
| 94 |
|
| 95 |
# set these to your network and netmask and ip |
| 96 |
# |
| 97 |
# This needs more work |
| 98 |
# |
| 99 |
;; |
| 100 |
|
| 101 |
[Ss][Ii][Mm][Pp][Ll][Ee]) |
| 102 |
############ |
| 103 |
# This is a prototype setup for a simple firewall. Configure this |
| 104 |
# machine as a named server and ntp server, and point all the machines |
| 105 |
# on the inside at this machine for those services. |
| 106 |
############ |
| 107 |
|
| 108 |
# |
| 109 |
# ND |
| 110 |
# |
| 111 |
# DAD |
| 112 |
${fw6cmd} add pass ipv6-icmp from ff02::/16 to :: |
| 113 |
${fw6cmd} add pass ipv6-icmp from :: to ff02::/16 |
| 114 |
# RS, RA, NS, NA, redirect... |
| 115 |
${fw6cmd} add pass ipv6-icmp from fe80::/10 to fe80::/10 |
| 116 |
${fw6cmd} add pass ipv6-icmp from fe80::/10 to ff02::/16 |
| 117 |
|
| 118 |
${fw6cmd} add pass tcp from any to any established |
| 119 |
|
| 120 |
# RIPng |
| 121 |
${fw6cmd} add pass udp from fe80::/10 521 to ff02::9 521 |
| 122 |
|
| 123 |
;; |
| 124 |
|
| 125 |
[Uu][Nn][Kk][Nn][Oo][Ww][Nn]) |
| 126 |
;; |
| 127 |
*) |
| 128 |
if [ -r "${firewall6_type}" ]; then |
| 129 |
${fw6cmd} ${firewall6_flags} ${firewall6_type} |
| 130 |
fi |
| 131 |
;; |
| 132 |
esac |