#!/bin/sh ############ # Setup system for firewall service. # $FreeBSD: src/etc/rc.firewall,v 1.30.2.4 2000/05/28 19:17:15 asmodai Exp $ fwcmd="/sbin/ipfw" ############ # Flush out the list before we begin. # ${fwcmd} -f flush ############ # This is a prototype setup for a simple firewall. Configure this # machine as a named server and ntp server, and point all the machines # on the inside at this machine for those services. ############ # set these to your outside interface network and netmask and ip oif="rl0" oip="wan ip here" onet="wan net here" omask="255.255.255.0" # set these to your inside interface network and netmask and ip iif="bge0" inet="10.0.0.0" imask="255.255.255.0" iip="10.0.0.1" # vpn vif="tun0" inet="192.168.9.0" imask="255.255.255.0" vip="192.168.9.1" ${fwcmd} add divert natd all from any to any via ${oif} ${fwcmd} add pass all from ${iip} to ${inet}:${imask} ${fwcmd} add pass all from ${inet}:${imask} to ${iip} ${fwcmd} add pass all from ${iip} to ${onet}:${omask} ${fwcmd} add pass all from ${onet}:${omask} to ${iip} # # TAS Govt. Network addresses # ${fwcmd} add pass all from any to 147.109.0.0/16 ${fwcmd} add pass all from 147.109.0.0/16 to any # # Networking Tasmania VPN Concentrator # ${fwcmd} add pass all from any to 203.49.97.228 ${fwcmd} add pass all from 203.49.97.228 to any # # Internode DNS Server # ${fwcmd} add pass all from any to 192.231.203.132 ${fwcmd} add pass all from 192.231.203.132 to any ${fwcmd} add pass all from any to 192.231.203.3 ${fwcmd} add pass all from 192.231.203.3 to any # # Deny incoming ICMP requests #${fwcmd} add deny log icmp from any to any in via ${oif} icmptypes 8 # Allow all ICMP ${fwcmd} add add allow icmp from any to any # Allow ping out and receive response back ${fwcmd} add allow icmp from any to any icmptypes 8 out ${fwcmd} add allow icmp from any to any icmptypes 0 in # Allow traceroute ${fwcmd} add allow icmp from any to any icmptypes 11 in # Allow VPN pings ${fwcmd} add pass icmp from 192.168.9.0/24 to 192.168.9.0/24 in via tun0 icmptypes 0 ${fwcmd} add pass icmp from 192.168.9.0/24 to 192.168.9.0/24 out via tun0 icmptypes 0 # Stop spoofing ${fwcmd} add deny all from ${inet}:${imask} to any in via ${oif} ${fwcmd} add deny all from ${onet}:${omask} to any in via ${iif} # Stop RFC1918 nets on the outside interface #${fwcmd} add deny all from 10.0.0.0/8 to any via ${oif} #${fwcmd} add deny all from any to 10.0.0.0/8 via ${oif} #${fwcmd} add pass all from 172.16.1.0/24 to any via ${oif} #${fwcmd} add deny all from any to 172.16.0.0/12 via ${oif} #${fwcmd} add deny all from 192.168.0.0/16 to any via ${oif} #${fwcmd} add deny all from any to 192.168.0.0/16 via ${oif} # Stop draft-manning-dsua-01.txt nets on the outside interface ${fwcmd} add deny all from 0.0.0.0/8 to any via ${oif} ${fwcmd} add deny all from any to 0.0.0.0/8 via ${oif} ${fwcmd} add deny all from 169.254.0.0/16 to any via ${oif} ${fwcmd} add deny all from any to 169.254.0.0/16 via ${oif} ${fwcmd} add deny all from 192.0.2.0/24 to any via ${oif} ${fwcmd} add deny all from any to 192.0.2.0/24 via ${oif} ${fwcmd} add deny all from 224.0.0.0/4 to any via ${oif} ${fwcmd} add deny all from any to 224.0.0.0/4 via ${oif} ${fwcmd} add deny all from 240.0.0.0/4 to any via ${oif} ${fwcmd} add deny all from any to 240.0.0.0/4 via ${oif} # Allow TCP through if setup succeeded ${fwcmd} add pass tcp from any to any established # Allow IP fragments to pass through ${fwcmd} add pass all from any to any frag # Allow access to ssh ${fwcmd} add pass tcp from any to ${oip} 22 setup ${fwcmd} add pass tcp from any to ${oip} 22 # Allow setup of incoming email ${fwcmd} add pass tcp from any to ${oip} 25 setup # Allow access to our DNS ${fwcmd} add pass tcp from any to ${oip} 53 setup ${fwcmd} add pass udp from any to ${oip} 53 ${fwcmd} add pass udp from ${oip} 53 to any # Allow access inside LAN subnet DNS lookups from this server ${fwcmd} add pass tcp from 10.0.0.0/24 to 10.0.0.1 53 setup ${fwcmd} add pass udp from 10.0.0.0/24 to 10.0.0.1 53 ${fwcmd} add pass udp from 10.0.0.1 53 to any # Allow access to our WWW ${fwcmd} add pass tcp from any to ${oip} 80 setup # Reject&Log all setup of incoming connections from the outside ${fwcmd} add deny log tcp from any to any in via ${oif} setup # Allow setup of any other TCP connection ${fwcmd} add pass tcp from any to any setup # Allow DNS queries out in the world ${fwcmd} add pass udp from any 53 to ${oip} ${fwcmd} add pass udp from ${oip} to any 53 # Allow NTP queries out in the world ${fwcmd} add pass udp from any 123 to ${oip} ${fwcmd} add pass udp from ${oip} to any 123 # Allow ports for MSN Messenger ${fwcmd} add pass tcp from any to ${oip} 6891-6900 setup ${fwcmd} add pass tcp from any to ${oip} 6891-6900 # Allow DHCP requests locally ${fwcmd} add allow udp from any to 10.0.0.0/24 546 ${fwcmd} add allow udp from any to 10.0.0.0/24 547 ${fwcmd} add allow udp from any to 10.0.0.0/24 67 ${fwcmd} add allow udp from any to 10.0.0.0/24 68