Date: Sat, 18 Nov 2000 15:54:47 -0800 From: "Crist J . Clark" <cjclark@reflexnet.net> To: Sam Carleton <scarleton@bigfoot.com> Cc: security@FreeBSD.ORG Subject: Re: help setting up a filewall Message-ID: <20001118155447.K9740@149.211.6.64.reflexcom.com> In-Reply-To: <3A16C44B.4DEC2492@bigfoot.com>; from scarleton@bigfoot.com on Sat, Nov 18, 2000 at 01:02:51PM -0500 References: <3A16C44B.4DEC2492@bigfoot.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--SLDf9lqlvOQaIe6s Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit [Maybe it's just me, but I think that generic "how do I set up a firewall?" questions are better suited for -questions. If you have specific ipfw questions, there is the -ipfw list too. But I can understand why people ask here.] On Sat, Nov 18, 2000 at 01:02:51PM -0500, Sam Carleton wrote: > I have read through the “Setting-up a Dual-Homed Host using IPFW and > NATD”, but the script is not working for me. My setup is a bit > different. My connectivity is via a cable modem. > > * In the article, it looks like the author was setup with a static > external IP address. I have a dynamic ip address. How do I allow the > DHCP server (Cable Modem) broadcasts to get to my outside NIC? Here's what I do, ############ # Info about local net numbers dhcpc_fxp0="64.6.192.0/19" dhcps_fxp0="${dhcpc_fxp0}" net="192.0.2.0/24" iip="192.0.2.254" ibc="192.0.2.255" iif="de0" oif=${natd_interface} # This is a little more efficient, only one ifconfig(8) call set -- `/sbin/ifconfig ${natd_interface} | /usr/bin/fgrep -w inet` oip="$2" obc="$6" [snip] ############ # Let external DHCP work for dhclient_interface in ${network_interfaces}; do eval ifconfig_args=\$ifconfig_${dhclient_interface} case ${ifconfig_args} in [Dd][Hh][Cc][Pp]) eval dhcpc_range=\$dhcpc_$dhclient_interface eval dhcps_range=\$dhcps_$dhclient_interface $fwcmd add pass udp from ${dhcpc_range} 68 to ${dhcps_range} 67 out via ${dhclient_interface} $fwcmd add pass udp from ${dhcps_range} 67 to ${dhcpc_range} 68 in via ${dhclient_interface} $fwcmd add pass udp from 0.0.0.0 68 to 255.255.255.255 67 out via ${dhclient_interface} $fwcmd add pass udp from ${dhcps_range} 67 to 255.255.255.255 68 in via ${dhclient_interface} ;; esac done > * In the article, the author is only allowing the inside connections to > connect to known DNS servers. I run a caching DNS server on the inside > so I need to have the firewall configured so that the internal DNS > server can talk to any other DNS server. These two are only safe to do after you've stopped spoofing and other stuff like that, $fwcmd add pass udp from ${dns_server} to any 53 keep-state $fwcmd add pass tcp from ${dns_server} to any 53 keep-state > * 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. > 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. I attached a little script I use to help debug my rulesets. It's really simple; it just cuts down on the verbosity of 'ipfw show' a bit. With some minor mods, it can also really nicely work on the rc.firewall script (although it does even help as-is). > ------------rc.conf------------ > 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" When posting questions of this sort, entries relavent to interface setup should be included as well. > ------------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 $ This is a fairly old version of rc.firewall. [snip] > [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.0.0" > imask="255.255.255.0" > iip="192.168.0.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} > > # 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 out via ${oif} > ${fwcmd} add deny all from 172.16.0.0/12 to any via ${oif} > ${fwcmd} add deny all from any to 172.16.0.0/12 out 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 out 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} I'd log the above since you should not be seeing them and they can help debug broken NAT setups. > # 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 tcp log tcp from any to any 21 in via ${oif} setup ^^^ Typo. > # 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 setup of any other TCP connection > ${fwcmd} add pass tcp from any to any setup > > # Allow access to our DNS > # ${fwcmd} add pass tcp from any to ${oif} 53 setup > # ${fwcmd} add pass udp from any to ${oif} 53 > # ${fwcmd} add pass udp from ${oif} 53 to any > > # Allow DNS queries out in the world > ${fwcmd} add pass udp from any 53 to ${oif} > ${fwcmd} add pass udp from ${oif} to any 53 These two previous sets of rules are messed up. You are using an interface as a source and destination argument. > # 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. > ;; [snip] -- Crist J. Clark cjclark@alum.mit.edu --SLDf9lqlvOQaIe6s Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=ipfwsh #!/bin/sh # # ipfwsh - 2000/10/28, cjc # # Cut down verbosity of 'ipfw show' output if [ $# -gt 1 ]; then # Bad command line echo "ipfwsh: bad args" >&2 echo "Usage: ipfwsh [iface]" >&2 exit 1 elif [ $# -eq 0 ]; then # Print whole list, just cut expired dynamic rules ipfw show | awk -F'[ ,]' '$5 != 0 { print }' else # An interface name was given, note there is no failure if # name is not valid ipfw show | awk -v"iface=$1" '/^## Dynamic rules:/ { exit } $0 ~ iface { print; next } /(via|recv|xmit)/ { next } { print }' fi --SLDf9lqlvOQaIe6s-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-security" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20001118155447.K9740>