From owner-freebsd-questions@FreeBSD.ORG Mon Sep 1 14:39:53 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 17A5916A4BF for ; Mon, 1 Sep 2003 14:39:53 -0700 (PDT) Received: from lakemtao08.cox.net (lakemtao08.cox.net [68.1.17.113]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0790D43F3F for ; Mon, 1 Sep 2003 14:39:52 -0700 (PDT) (envelope-from micheal@cancercare.net) Received: from dredster ([68.12.67.176]) by lakemtao08.cox.net (InterMail vM.5.01.06.04 201-253-122-130-104-20030726) with SMTP id <20030901213950.UHHT19774.lakemtao08.cox.net@dredster>; Mon, 1 Sep 2003 17:39:50 -0400 Message-ID: <046f01c370d1$9eff8ed0$0201a8c0@dredster> From: "Micheal Patterson" To: "Arvinn" , References: <4438.212.71.64.140.1062415470.squirrel@webmail.sandakeronline.com> Date: Mon, 1 Sep 2003 16:40:08 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Subject: Re: ipfw with four interfaces X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Sep 2003 21:39:53 -0000 ----- Original Message ----- From: "Arvinn" To: Sent: Monday, September 01, 2003 6:24 AM Subject: ipfw with four interfaces > This FreeBSD 4.x with ipfw1 have four interfaces: > > fxp0: flags=8843 mtu 1500 > inet w.x.y.81 netmask 0xfffffff0 broadcast w.x.y.95 > xl0: flags=8843 mtu 1500 > inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255 > xl1: flags=8843 mtu 1500 > inet 172.16.0.1 netmask 0xffffff00 broadcast 172.16.0.255 > xl2 is the interface that is connected back-to-back with the router. > > As you can see, hosts on xl0 and xl1 need to get translated in order to > get on the Internet. The dmz is for a few web-servers, a mailserver and a > vpn-gateway I will be setting up later. I have a hard time getting this > design to actually work with deny ip from any to any in the bottom of the > ruleset. > > I thought my tcp/ip skills were proper but after I started dealing with > this I feel like a complete noob. > > Here are the rules I haave written so far: > > # more fwrules > fwcmd="/sbin/ipfw" > extif="xl2" > dmzif="fxp0" > lanif="xl0" > motorif="xl1" > > $fwcmd -f flush > ### > $fwcmd add 100 allow all from any to any via lo0 > $fwcmd add 200 deny all from any to 127.0.0.0/8 > $fwcmd add 300 deny ip from 127.0.0.0/8 to any > $fwcmd add 500 deny tcp from any to any in via any tcpflags syn,fin > $fwcmd add 600 deny ip from any to any in via any frag > ### > $fwcmd add 900 allow tcp from an.outside.net.work to me ssh in via $extif > # This one passes packets to natd. If I knew how to divert only rfc1918 > addresses are passed to natd I would do that. > # In the meantine I have configured natd with the unregistered-flag. > $fwcmd add 950 divert natd all from any to any via $extif > # Allow http to the whole dmz from Internet: > $fwcmd add 1000 allow tcp from any to w.x.y.80/28 http via $extif > # Allow smtp and pop3 to the mailserver from Internet: > $fwcmd add 1050 allow tcp from any to w.x.y.84 smtp,pop3 via $extif > # > # With the following rules I want to allow all traffic between my own > segments: > $fwcmd add 1200 allow ip from any to any via $dmzif > $fwcmd add 1250 allow ip from any to any via $lanif > $fwcmd add 1300 allow ip from any to any via $motorif > # Allow all traffic out to Internett: > $fwcmd add 2000 allow ip from any to any out via $extif > # Allow all icmp for testing purposes until I get the firewll rules working: > $fwcmd add 3000 allow icmp from any to any via any > > # Blocking ports out to Internet that I don't like: > $fwcmd add 1300 deny tcp from any to any 135-139 out via $extif > $fwcmd add 1350 deny tcp from any to any 445 out via $extif > ### > # Blocking everything else: > $fwcmd add 65000 deny ip from any to any > # > > When I load these rules it looks like "nothing" but icmp works. The > computers on the the rfc1918 addresses can't speak tcp (and probably udp > as well) and the computers on the dmz can neither. I feel I don't > understand this properly. There must be some basic errors with my ruleset. > Will it help me to put in this at the top?: > > $fwcmd add 50 check-state > > ..and then use keep-state on all my allow rules? > > Can someone please: > > I would be greatful for all kind of answers. > > Arvinn > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" > Try having the very first rule divert ip from any to any to natd Then, you can configure NATD to only effect RFC1918 packets by adding a -u to the command line. NAT will take the packet, process it if it's an RFC 1918 address, if not, allow it to pass and then reinject it into the firewall at rule 2 (or next available rule) and continue processing the ruleset. I've not been awake for long and have had little to no Mt Dew yet so don't hold this against me. Without going over this for awhile, which I recommend when doing a firewall, this may be something in the neighborhood that you're looking for. In your /usr/local/etc/natd.sh #!/bin/sh natd -interface xl2 -s -m -u Or if you start it from rc.conf: natd_flags="-s -m -u " The -s tells it to use sockets so that FTP doesn't get broken. You may not need this. The -m tells natd to attempt to use the same socket as the originating host. The -u tells natd to only translate RFC 1918 packets. In your firewall rules file: ############### # more fwrules fwcmd="/sbin/ipfw" extif="xl2" dmzif="fxp0" lanif="xl0" motorif="xl1" # # $fwcmd -f flush # # #NATD Divert $fwcmd add 1 divert natd all from any to any via xl2 # #You want blocked outbound ports to match early on in the firewall. # # Blocking ports out to Internet that I don't like: $fwcmd add 100 deny tcp from any to any 135-139 out via $extif $fwcmd add 100 deny tcp from any to any 445 out via $extif # #Then your allows: # #Network Allows $fwcmd add 300 allow ip from any to any via $extif $fwcmd add 300 allow ip from any to any via $dmxif $fwcmd add 300 allow ip from any to any via $lanif $fwcmd add 300 allow ip from any to any via $motorif # # Allow http to the whole dmz from Internet: $fwcmd add 400 allow tcp from any to w.x.y.80/28 http via $extif # # Allow smtp and pop3 to the mailserver from Internet: $fwcmd add 500 allow tcp from any to w.x.y.84 smtp,pop3 via $extif # #Lastly, your denies # #Network Denies # # Default Block $fwcmd add 65000 deny ip from any to any Hope this helps you out. -- Micheal Patterson Network Administration Cancer Care Network 405-917-0600