From owner-freebsd-questions@freebsd.org Thu Nov 16 20:02:16 2017 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B5344DE7AC1 for ; Thu, 16 Nov 2017 20:02:16 +0000 (UTC) (envelope-from tundra@tundraware.com) Received: from oceanview.tundraware.com (oceanview.tundraware.com [45.55.60.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mailman.tundraware.com", Issuer "mailman.tundraware.com" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 5D5436836B for ; Thu, 16 Nov 2017 20:02:15 +0000 (UTC) (envelope-from tundra@tundraware.com) Received: from [192.168.0.2] (ozzie.tundraware.com [75.145.138.73]) (authenticated bits=0) by oceanview.tundraware.com (8.15.2/8.15.2) with ESMTPSA id vAGK23vO016880 (version=TLSv1.2 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 16 Nov 2017 14:02:03 -0600 (CST) (envelope-from tundra@tundraware.com) Subject: Re: IPFW: Why can I add port numbers to established and what does that do ? To: javocado , freebsd-questions@freebsd.org References: From: Tim Daneliuk Message-ID: Date: Thu, 16 Nov 2017 14:01:58 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.2 (oceanview.tundraware.com [45.55.60.57]); Thu, 16 Nov 2017 14:02:03 -0600 (CST) X-TundraWare-MailScanner-Information: Please contact the ISP for more information X-TundraWare-MailScanner-ID: vAGK23vO016880 X-TundraWare-MailScanner: Found to be clean X-TundraWare-MailScanner-SpamCheck: not spam (whitelisted), SpamAssassin (not cached, score=-0.898, required 1, autolearn=not spam, ALL_TRUSTED -1.00, AWL 0.10, RP_MATCHES_RCVD -0.00) X-TundraWare-MailScanner-From: tundra@tundraware.com X-Spam-Status: No X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Nov 2017 20:02:16 -0000 On 11/16/2017 01:29 PM, javocado wrote: > Almost every single ipfw ruleset I create has this as the very first rule: > > allow tcp from any to any established > > ... and I just noticed that ipfw allows me to specify a port on this rule: > > allow tcp from any to any 22 established > > If I create a new connection to port 22, I need a rule to allow port 22 > traffic out: > > allow tcp from any to any 22 > > ... but once that connection is established, doesn't the client begin > talking to the server on an ephemeral port (not 22) that isn't predictable ? > > Why would it ever make sense to specify a port on established ? If you are running your own sshd *server*, then you need rules that allow all or some to connect *to* your machine. If you are running an ssh *client*, you need to first allow access *out* via port 22 to get to the remote servers. Thereafter - as you suggest - the server and client rendezvous and establish a permanent connection on another port (and the server goes back to listening on 22). So, the firewall has to permit access to the established session w/o knowing which port will be used ahead of time. ---------------------------------------------------------------------------- Tim Daneliuk tundra@tundraware.com PGP Key: http://www.tundraware.com/PGP/