From owner-freebsd-net@freebsd.org Fri Nov 22 06:19:52 2019 Return-Path: Delivered-To: freebsd-net@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9F43C1ADDBD for ; Fri, 22 Nov 2019 06:19:52 +0000 (UTC) (envelope-from vas@sibptus.ru) Received: from admin.sibptus.ru (admin.sibptus.ru [IPv6:2001:19f0:5001:21dc::10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 47K5r73wBZz4PL0 for ; Fri, 22 Nov 2019 06:19:51 +0000 (UTC) (envelope-from vas@sibptus.ru) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sibptus.ru; s=20181118; h=In-Reply-To:Message-ID:Subject:To:From:Date; bh=DF5qEhhK0iILIFNfkCG4vexML9ggK294oyPpcMAzpo0=; b=oOlXKhpkxL/YPr5M7ewFxkxNgq tu1K77w1Y0a8OT/0KPhh5LeOUrbYFSly9HpBERbiKCNgI8TWcAlk3jncKHbomDx96+4ZTUplOV8Tl cSqEiwGrfluVoPeEW5TRTDbl4zave9Ee7I5naBc/XYg2JcMo4Dh8KEIWng2Mqn0UM5fE=; Received: from vas by admin.sibptus.ru with local (Exim 4.92.3 (FreeBSD)) (envelope-from ) id 1iY2II-0006lE-56 for freebsd-net@freebsd.org; Fri, 22 Nov 2019 13:19:50 +0700 Date: Fri, 22 Nov 2019 13:19:50 +0700 From: Victor Sudakov To: freebsd-net@freebsd.org Subject: Re: pf, stateful filter and DMZ Message-ID: <20191122061950.GA25286@admin.sibptus.ru> References: <20191121151041.GA93735@admin.sibptus.ru> <59ac7be3-b79d-a13e-b64f-cd4dae43b9e4@tuxpowered.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="TB36FDmn/VVEgNH/" Content-Disposition: inline In-Reply-To: <59ac7be3-b79d-a13e-b64f-cd4dae43b9e4@tuxpowered.net> X-PGP-Key: http://admin.sibptus.ru/~vas/ X-PGP-Fingerprint: 10E3 1171 1273 E007 C2E9 3532 0DA4 F259 9B5E C634 User-Agent: Mutt/1.12.2 (2019-09-21) X-Rspamd-Queue-Id: 47K5r73wBZz4PL0 X-Spamd-Bar: -------- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=sibptus.ru header.s=20181118 header.b=oOlXKhpk; dmarc=pass (policy=none) header.from=sibptus.ru; spf=pass (mx1.freebsd.org: domain of vas@sibptus.ru designates 2001:19f0:5001:21dc::10 as permitted sender) smtp.mailfrom=vas@sibptus.ru X-Spamd-Result: default: False [-8.40 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_DKIM_ALLOW(-0.20)[sibptus.ru:s=20181118]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+mx:c]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.20)[multipart/signed,text/plain]; TO_DN_NONE(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; RCPT_COUNT_ONE(0.00)[1]; IP_SCORE(-3.30)[ip: (-9.85), ipnet: 2001:19f0:5000::/38(-4.93), asn: 20473(-1.69), country: US(-0.05)]; DKIM_TRACE(0.00)[sibptus.ru:+]; DMARC_POLICY_ALLOW(-0.50)[sibptus.ru,none]; SIGNED_PGP(-2.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:20473, ipnet:2001:19f0:5000::/38, country:US]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Nov 2019 06:19:52 -0000 --TB36FDmn/VVEgNH/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Kajetan Staszkiewicz wrote: > > A quick question about pf from an ipfw user. > >=20 > > Suppose I have three interfaces: $outside, $inside and $dmz. If I want > > to block any traffic from $dmz to $inside, unless it is=20 > >=20 > > 1. Return traffic from $inside to $dmz I think I actually meant "return traffic from $dmz_net to $inside_net".=20 >=20 > pf is a stateful firewall and you can't really skip its statefullness. > It will always allow return traffic if you allowed outgoint connection. I know that, the question is rather how to *create* the state when traffic passes from $inside_net to $dmz_net because it's permitted by default. So I just need a "pass" rule to create state, even if otherwise this rule does nothing? >=20 > > 2. ICMP traffic in any direction >=20 > Sounds like a bad idea. Why would you do it? Well, for example, if a host in $inside_net sends a UDP datagram to a host in $dmz_net which generates an ICMP port unreachable message, I want the host in $inside_net to actually receive the message. If pf is THAT stateful and smart, then this rule is not necessary. >=20 > > would these rules be sufficient? > >=20 > > block in on $dmz To be more precise, it would be block in on $dmz from any to $inside_net pass in on $dmz proto icmp from any to $inside_net pass out on $inside ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The last rule will actually create the state for return traffic, is it correct? >=20 > For me this rather looks like you allow from $dmz to $inside but block > from $dmz to $outside.=20 Corrected above. > Rules are not "quick" so the last one matching > applies. However somebody else should verify this, I'm always only using > quick rules so I'm not 100% sure. As a person with some ipfw background, I try to take advantage of pf's features, e.g. "last match wins." Maybe it allows for more concise rules. --=20 Victor Sudakov, VAS4-RIPE, VAS47-RIPN 2:5005/49@fidonet http://vas.tomsk.ru/ --TB36FDmn/VVEgNH/ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJd134GAAoJEA2k8lmbXsY0538H/0qjjdE/3wXy2YIxbM7m3ehy IaAwcnDAEkckVZkV7f/R6Oeq+evzXV3BHCmJgzf4GS5hPoimynMHwwMRZuPBY3dB HKAUeSEFieQLwPJXLXSB79tPLfbTXpq/XmssjW3TuTnZQci7LYjSGIkjSjRO2fD2 QGdiYRWmfov/7b+hz/o2OIFnCgtpQYvSgwBPE0e6v26S5/09xbDYcFnGVZ3ypSfd RvtEw8kY2vL4ZeV9+ZPvCMcuJLWryqfA0QjnHxqL/KeQ757nJCengylmOPndUWQW Sjyiao14CR5zARm66fP0/Xh3dEk8caxdZN6ipsTK62VnWTRuqaIy0TMnObRlazU= =mOXV -----END PGP SIGNATURE----- --TB36FDmn/VVEgNH/--