From owner-freebsd-net@freebsd.org Tue Apr 2 07:03:49 2019 Return-Path: Delivered-To: freebsd-net@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5CD0E155A5E1 for ; Tue, 2 Apr 2019 07:03:49 +0000 (UTC) (envelope-from vas@mpeks.tomsk.su) 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 741FF76F92 for ; Tue, 2 Apr 2019 07:03:48 +0000 (UTC) (envelope-from vas@mpeks.tomsk.su) 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=wtqww5uHAIr55fSRjkAzf0uA4tVbEKtR22R4lQZp750=; b=oCt0Qt3NE19hB5YQ1c+qcamm1j 9iAnE4mKm/C5EkDCPO8qrunGj3UhVNY5mNuR3vqOLUl+iVIee9rmtF9gtyYH0q1kLRHvWtf08lOQf 59PZG4WjUFxXIh0bULN/AYDdFBEd3bH7yBETnqYYdBSrOVkVfBsVvN/B8L1ODH9BmXcY=; Received: from vas by admin.sibptus.ru with local (Exim 4.92 (FreeBSD)) (envelope-from ) id 1hBDSU-00041v-67 for freebsd-net@freebsd.org; Tue, 02 Apr 2019 14:03:46 +0700 Date: Tue, 2 Apr 2019 14:03:46 +0700 From: Victor Sudakov To: freebsd-net@freebsd.org Subject: Re: need help with ipfw nat to pf nat migration Message-ID: <20190402070346.GA15400@admin.sibptus.ru> References: <20190401033424.GA95019@admin.sibptus.ru> <75502aa3-0e10-fbba-d56b-5716e91e7b27@akhmatov.ru> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="+QahgC5+KEYLbs62" Content-Disposition: inline In-Reply-To: <75502aa3-0e10-fbba-d56b-5716e91e7b27@akhmatov.ru> X-PGP-Key: http://www.dreamwidth.org/pubkey?user=victor_sudakov X-PGP-Fingerprint: 10E3 1171 1273 E007 C2E9 3532 0DA4 F259 9B5E C634 User-Agent: Mutt/1.11.4 (2019-03-13) Sender: Victor Sudakov 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: Tue, 02 Apr 2019 07:03:49 -0000 --+QahgC5+KEYLbs62 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Sergey Akhmatov wrote: > >=20 > > I'm trying to migrate some firewall rules from ipfw to pf. As pf does > > NAT first and filtering after NAT, I have a problem doing the following: > >=20 > > 1. All 192.168.0.0/16 addresses should be translated to the real IP of > > the external interface. > >=20 > > 2. A subset of the 192.168.0.0/16, for example 192.168.3.0/24, > > should have access only to a limited list of addresses in the Internet, > > for example 8.8.8.8 only. > >=20 > > However, because the "nat" rule has already done its job before > > filtering, I cannot "block on $ext_if from 192.168.3.0/24 to any" > > because the source has already been translated. > >=20 > > In ipfw I can "deny ip from 192.168.3.0/24 to not 8.8.8.8" before it > > even gets into the nat rule, but what do I do with pf? > >=20 > Try using "no nat". >=20 > table {8.8.8.8, ..... } > nat pass on $ext_if from 192.168.3.0/24 to -> $(ext_if) > no nat on ext_if from 192.168.3.0/24 to any > nat pass on $ext_if from 192.168.0.0/16 to any -> $(ext_if) Thank you Sergey, I get the idea. It is not very good though that packets from 192.168.3.0/24 to not will get into the Internet with the untranslated private src address. I guess I need to complete the configuration by a rule something like block out on $(ext_if) from 192.168.3.0/24 to any Is that right? Or probably add a rule to block all trafic from 192.168.0.0/16 out via $ext= _if. --=20 Victor Sudakov, VAS4-RIPE, VAS47-RIPN 2:5005/49@fidonet http://vas.tomsk.ru/ --+QahgC5+KEYLbs62 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJcowlSAAoJEA2k8lmbXsY0a1QH/3ot3lM2cpKTnucgdMwXWRAX ccG4BNiUJ0DjHhWPeYnCXK2i2PBqluss2VOREykMvO30jcPZZoMLNGabV39U1h6V kpgfIGnW8XDRW6iQFmvqrbN0cYMKwxAkKXk4K7jlzEIKJEakHUXmbzRpiTH5088C K5NgOqLc4PG5yjVvvhK4UNnpg0CCaDnPttbg53U+Zl54mKLBbi0aFZc3AK4CyDXD kwQy229XsdKlKZ9R5gpDqGTAZ+/oEZb61Y/PzjJi8WAcudm+BNOYuC37VyEFPe2f pGJ/wjLodn0WXDZfhUQ+/81wH7sVHljC5MvbJJe7GSoowCwcX3gWi2Rzyhru0rM= =+QY2 -----END PGP SIGNATURE----- --+QahgC5+KEYLbs62--