From owner-freebsd-security Sun Nov 19 12:13:37 2000 Delivered-To: freebsd-security@freebsd.org Received: from ipass.one.net (news2.one.net [206.112.192.118]) by hub.freebsd.org (Postfix) with ESMTP id 61B1C37B479 for ; Sun, 19 Nov 2000 12:13:26 -0800 (PST) Received: from bigfoot.com (cvg-27-180-111.cinci.rr.com [24.27.180.111]) by ipass.one.net (8.8.7/8.8.7) with ESMTP id PAA06421 for ; Sun, 19 Nov 2000 15:17:07 -0500 Message-ID: <3A1833F4.A2A25FBC@bigfoot.com> Date: Sun, 19 Nov 2000 15:11:32 -0500 From: Sam Carleton X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: "security@FreeBSD.ORG" Subject: Re: help setting up a filewall References: <3A16C44B.4DEC2492@bigfoot.com> <20001118155447.K9740@149.211.6.64.reflexcom.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-security@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org "Crist J . Clark" wrote: > > * In the article, it looks like the author is allowing things like HTTP > > and SSH to come into the firewall machine. I want those things to be > > passed onto another internal machine. > > The rules may or may not change depending on where they are relative > to the divert(4) rule. Also, see 'redirect_address' and > 'redirect_port' in natd(8). You did not post your natd.conf, so I > can't tell if you are already using those. Sorry about that, this time I will including EVERYTHING :) > > Attached you will find my modifications to the rc.firewall script and > > relavent snips of rc.conf. If you have any thoughts on what I am doing > > wrong, please drop me an email. Thanks! > > A few nitpicks about your ruleset, but nothing absolutely leaped out > at me as a problem that would totally break everything. Since you did > not tell us exactly what kind of problem you are having, it's hard to > know what to look for. Well, the problem I am currently having is with DNS. The test enviornment that I have setup is such that there is no DNS server behind the FreeBSD firewall. The machine inside the firewall is not able to get a DNS request out. To make things more interesting, while booting the FreeBSD firewall, the rc.firewall script ALWAYS hangs on the two DNS lines. # Allow DNS queries out in the world ${fwcmd} add pass udp from ${iif} to any 53 keep-state ${fwcmd} add pass tcp from ${iif} to any 53 keep-state The setup I am looking for is one where anyone on the inside can get to any DNS server on the outside. I am going to have one caching DNS server on the inside, but if that is down, the clients will be configured to goto a DNS server outside the firewall. What rules would you setup for this configuration? This is what I have currently: -----------rc.conf----------- gateway_enable="YES" hostname="orchid.miltonstreet.com" ifconfig_ep0="DHCP" ifconfig_xl0="inet 192.168.100.6 netmask 255.255.255.0" inetd_enable="Yes" moused_enable="YES" nisdomainname="NO" router_enable="No" saver="fire" sendmail_enable="NO" sshd_enable="NO" usbd_enable="YES" firewall_enable="Yes" firewall_type="Simple" firewall_script="/etc/rc.firewall" firewall_quite="No" natd_program="/sbin/natd" natd_enable="Yes" natd_interface="ep0" natd_flags="-f /etc/natd.conf" -----------natd.conf----------- dynamic yes use_sockets yes same_ports yes -----------rc.firewall----------- ############ # Setup system for firewall service. # $FreeBSD: src/etc/rc.firewall,v 1.30.2.4 2000/05/28 19:17:15 asmodai Exp $ # Suck in the configuration variables. if [ -r /etc/defaults/rc.conf ]; then . /etc/defaults/rc.conf source_rc_confs elif [ -r /etc/rc.conf ]; then . /etc/rc.conf fi ############ # Define the firewall type in /etc/rc.conf. Valid values are: # open - will allow anyone in # simple - will try to protect a whole network # closed - totally disables IP services except via lo0 interface # UNKNOWN - disables the loading of firewall rules. # filename - will load the rules in the given filename (full path required) # # For ``simple'' the entries below should be customized # appropriately. ############ # # If you don't know enough about packet filtering, we suggest that you # take time to read this book: # # Building Internet Firewalls # Brent Chapman and Elizabeth Zwicky # # O'Reilly & Associates, Inc # ISBN 1-56592-124-0 # http://www.ora.com/ # # For a more advanced treatment of Internet Security read: # # Firewalls & Internet Security # Repelling the wily hacker # William R. Cheswick, Steven M. Bellowin # # Addison-Wesley # ISBN 0-201-6337-4 # http://www.awl.com/ # if [ -n "${1}" ]; then firewall_type="${1}" fi ############ # Set quiet mode if requested # case ${firewall_quiet} in [Yy][Ee][Ss]) fwcmd="/sbin/ipfw -q" ;; *) fwcmd="/sbin/ipfw" ;; esac ############ # Flush out the list before we begin. # ${fwcmd} -f flush ############ # These rules are required for using natd. All packets are passed to # natd before they encounter your remaining rules. The firewall rules # will then be run again on each packet after translation by natd, # minus any divert rules (see natd(8)). # case ${natd_enable} in [Yy][Ee][Ss]) if [ -n "${natd_interface}" ]; then ${fwcmd} add 50 divert natd all from any to any via ${natd_interface} fi ;; esac ############ # If you just configured ipfw in the kernel as a tool to solve network # problems or you just want to disallow some particular kinds of traffic # then you will want to change the default policy to open. You can also # do this as your only action by setting the firewall_type to ``open''. # # ${fwcmd} add 65000 pass all from any to any ############ # Only in rare cases do you want to change these rules # ${fwcmd} add 100 pass all from any to any via lo0 ${fwcmd} add 200 deny all from any to 127.0.0.0/8 # If you're using 'options BRIDGE', uncomment the following line to pass ARP #${fwcmd} add 300 pass udp from 0.0.0.0 2054 to 0.0.0.0 # Prototype setups. # case ${firewall_type} in [Oo][Pp][Ee][Nn]) ${fwcmd} add 65000 pass all from any to any ;; [Ss][Ii][Mm][Pp][Ll][Ee]) ############ # 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="ep0" # onet="192.0.2.0" # omask="255.255.255.240" # oip="192.0.2.1" # set these to your inside interface network and netmask and ip iif="xl1" inet="192.168.100.0" imask="255.255.255.0" iip="192.168.100.6" # 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} # allow DHCP stuff ${fwcmd} add pass udp from any 67 to any 68 in via ${oif} ${fwcmd} add pass udp from any 68 to any 67 out via ${oif} # Stop RFC1918 nets on the outside interface ${fwcmd} add deny log all from 10.0.0.0/8 to any via ${oif} ${fwcmd} add deny log all from any to 10.0.0.0/8 out via ${oif} ${fwcmd} add deny log all from 172.16.0.0/12 to any via ${oif} ${fwcmd} add deny log all from any to 172.16.0.0/12 out via ${oif} # ${fwcmd} add deny log all from 192.168.0.0/16 to any via ${oif} # ${fwcmd} add deny log all from any to 192.168.0.0/16 out via ${oif} # Stop draft-manning-dsua-01.txt nets on the outside interface ${fwcmd} add deny log all from 0.0.0.0/8 to any via ${oif} ${fwcmd} add deny log all from any to 0.0.0.0/8 via ${oif} ${fwcmd} add deny log all from 169.254.0.0/16 to any via ${oif} ${fwcmd} add deny log all from any to 169.254.0.0/16 via ${oif} ${fwcmd} add deny log all from 192.0.2.0/24 to any via ${oif} ${fwcmd} add deny log all from any to 192.0.2.0/24 via ${oif} ${fwcmd} add deny log all from 224.0.0.0/4 to any via ${oif} ${fwcmd} add deny log all from any to 224.0.0.0/4 via ${oif} ${fwcmd} add deny log all from 240.0.0.0/4 to any via ${oif} ${fwcmd} add deny log 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 # HTTP - Allow access to our web server ${fwcmd} add pass tcp from any to any 80 setup # SMTP - Allow access to sendmail for incoming e-mail ${fwcmd} add pass tcp from any to any 25 setup # FTP - Allow incoming data channel for outgoing connections, # Reject&Log all incoming control connections ${fwcmd} add pass tcp from any 20 to any 1024-65535 setup ${fwcmd} add deny log tcp from any to any 21 in via ${oif} setup # SSH Login - Allow & Log all incoming ${fwcmd} add pass log tcp from any to any 22 in via ${oif} setup # IDENT - Reset incoming connections ${fwcmd} add reset tcp from any to any 113 in via ${oif} 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 DNS queries out in the world ${fwcmd} add pass udp from ${iif} to any 53 keep-state ${fwcmd} add pass tcp from ${iif} to any 53 keep-state # Allow setup of any other TCP connection ${fwcmd} add pass tcp from any to any setup # Allow NTP queries out in the world ${fwcmd} add pass udp from any 123 to any 123 via ${oif} ${fwcmd} add pass udp from any 123 to any via ${iif} ${fwcmd} add pass udp from any to any 123 via ${iif} # TRACEROUTE - Allow outgoing, but not incoming ${fwcmd} add pass udp from any to any 33434-33523 out via ${oif} ### ICMP RULES # ICMP packets # Allow all ICMP packets on internal interface ${fwcmd} add pass icmp from any to any via ${iif} # Allow outgoing pings, but not incoming ${fwcmd} add pass icmp from any to any icmptypes 8 out via ${oif} ${fwcmd} add pass icmp from any to any icmptypes 0 in via ${oif} # Allow Destination Unreachable, Source Quench, Time Exceeded, and Bad Head ${fwcmd} add pass icmp from any to any icmptypes 3,4,11,12 via ${oif} # Deny the rest of them ${fwcmd} add deny icmp from any to any # Everything else is denied by default, unless the # IPFIREWALL_DEFAULT_TO_ACCEPT option is set in your kernel # config file. ;; [Uu][Nn][Kk][Nn][Oo][Ww][Nn]) ;; *) if [ -r "${firewall_type}" ]; then ${fwcmd} ${firewall_flags} ${firewall_type} fi ;; esac To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-security" in the body of the message