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