From owner-freebsd-questions@FreeBSD.ORG Tue Aug 23 10:07:27 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org 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 05B9F16A41F; Tue, 23 Aug 2005 10:07:27 +0000 (GMT) (envelope-from Alexander@Leidinger.net) Received: from www.ebusiness-leidinger.de (jojo.ms-net.de [84.16.236.246]) by mx1.FreeBSD.org (Postfix) with ESMTP id 539AD43D45; Tue, 23 Aug 2005 10:07:25 +0000 (GMT) (envelope-from Alexander@Leidinger.net) Received: from Andro-Beta.Leidinger.net (p54A5D60A.dip.t-dialin.net [84.165.214.10]) (authenticated bits=0) by www.ebusiness-leidinger.de (8.13.1/8.13.1) with ESMTP id j7N9xvbd047316; Tue, 23 Aug 2005 12:00:09 +0200 (CEST) (envelope-from Alexander@Leidinger.net) Received: from localhost (localhost [127.0.0.1]) by Andro-Beta.Leidinger.net (8.13.3/8.13.3) with ESMTP id j7NA6UjJ019474; Tue, 23 Aug 2005 12:06:30 +0200 (CEST) (envelope-from Alexander@Leidinger.net) Received: from 141.113.101.31 ([141.113.101.31]) by netchild.homeip.net (Horde MIME library) with HTTP for ; Tue, 23 Aug 2005 12:06:30 +0200 Message-ID: <20050823120630.q2tfbx2kg44w8o4s@netchild.homeip.net> X-Priority: 3 (Normal) Date: Tue, 23 Aug 2005 12:06:30 +0200 From: Alexander Leidinger To: Stephen Major References: <43096afc.203c14ca.61c4.6d63@mx.gmail.com> In-Reply-To: <43096afc.203c14ca.61c4.6d63@mx.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format="flowed" Content-Disposition: inline Content-Transfer-Encoding: 7bit User-Agent: Internet Messaging Program (IMP) H3 (4.0.3) / FreeBSD-4.11 X-Virus-Scanned: by amavisd-new Cc: freebsd-security@freebsd.org, remko@freebsd.org, 'Pat Maddox' , 'FreeBSD Questions' Subject: RE: Security warning with sshd X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Aug 2005 10:07:27 -0000 Stephen Major wrote: > This is due to a mis-configured firewall. If you are using IPFW there are > many tutorials out there that tell you to do the wrong thing. And almost all > of them contradict each other. Below is a basic script that only allows in > and out SSH sessions and blocks all the garbage. Of coarse you must add any > other services you need. The key here is that you allow connections from any > to any established. Then on all outgoing tcp connections be sure to use the > setup keep-state flags. The keep-state flag puts the rule into the dynamic > rules table. Then the allow connections from any to any established allows > already established connections to flow without going through the ruleset > again. When I did this the error messages you are now experiencing went > away. I'm *dis*allowing established connections in my firewall, and everything works as expected. You just need to expect the right thing. :-) "established" is a non-stateful filter rule, so it matches on the presence/absence of some TCP flags. I can't get to the ipfw statistics yet, but tere are a lot of established packets which are rejected. Needless to say that there's normal traffic (ssh, https, smtp, imaps, ...) which goes through the firewall just well. > ### check the traffic's state > $ipfwcmd $flags add 00500 check-state Here you have the statefull equivalent of the "established" rule, so every successfully setup connection ("keep-state") already passes because of this rule. > $ipfwcmd $flags add 00501 allow tcp from any to any established Here you can switch to "reject" or "deny" instead of allowing it. Everything should just continue to work (if it doesn't, most likely you forgot a "keep-state" somewhere). With this a reconfiguration of the firewall results in dropping established connections. > ###### outbound section ###### > > ### Allow out ssh > $ipfwcmd $flags add 02150 allow tcp from me 22 to any out via $oif > setup keep-state What are you trying to do here? Outgoing connections from ssh clients have a src port above 1024. Bye, Alexander. -- http://www.Leidinger.net Alexander @ Leidinger.net: PGP ID = B0063FE7 http://www.FreeBSD.org netchild @ FreeBSD.org : PGP ID = 72077137 Avoid strange women and temporary variables.