From owner-freebsd-net@freebsd.org Thu Apr 4 04:30:07 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 317AC15618E6 for ; Thu, 4 Apr 2019 04:30:07 +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 98633843C3 for ; Thu, 4 Apr 2019 04:30:06 +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=ypCB6HZFeNhEt1RpZPwb4B2wvLlHhIwTAOZSd7gDAqI=; b=E4I//SNvoAVpnDHRVRb7HeIKVK dtnH4eHAaBHA6/iEvA/SPZuM6CcNdwRfU+P9s/vcYT1FfOYpXkwR7Opd7qYGfz0v2f0bobguhsGis H8YQAbIu69AqavxKJ1kh/UElv8eFD1Ubs3mi+H1jnMJOjUsJhE3t2YMbPUH/j/kbmer0=; Received: from vas by admin.sibptus.ru with local (Exim 4.92 (FreeBSD)) (envelope-from ) id 1hBu0q-0002zZ-TF for freebsd-net@freebsd.org; Thu, 04 Apr 2019 11:30:04 +0700 Date: Thu, 4 Apr 2019 11:30:04 +0700 From: Victor Sudakov To: freebsd-net@freebsd.org Subject: Re: need help with ipfw nat to pf nat migration Message-ID: <20190404043004.GA10861@admin.sibptus.ru> References: <20190401033424.GA95019@admin.sibptus.ru> <75502aa3-0e10-fbba-d56b-5716e91e7b27@akhmatov.ru> <20190402070346.GA15400@admin.sibptus.ru> <391e8839-00ce-0d2d-36e7-616c7d86cc30@viklenko.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="G4iJoqBmSsgzjUCe" Content-Disposition: inline In-Reply-To: <391e8839-00ce-0d2d-36e7-616c7d86cc30@viklenko.net> 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: Thu, 04 Apr 2019 04:30:07 -0000 --G4iJoqBmSsgzjUCe Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Artem Viklenko via freebsd-net wrote: > >>> > >>> 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 followi= ng: > >>> > >>> 1. All 192.168.0.0/16 addresses should be translated to the real IP of > >>> the external interface. > >>> > >>> 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 Interne= t, > >>> for example 8.8.8.8 only. > >>> > >>> 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 >=20 > You can tag packets on ingress interface and then filter on egress interf= ace=20 > based on this tag: >=20 1. > pass in quick on $int_if inet proto tcp from $server to any flags S/SA ke= ep state allow-opts tag SERVER 2. > block return-rst out log quick on $mob_if inet proto tcp to any port 25 t= agged SERVER You have already passed the packet with "quick" in the first rule, it probably will never hit the second "block" rule? --=20 Victor Sudakov, VAS4-RIPE, VAS47-RIPN 2:5005/49@fidonet http://vas.tomsk.ru/ --G4iJoqBmSsgzjUCe Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJcpYhMAAoJEA2k8lmbXsY0x8QH/jTSJZrBT3A8p9TMImdq4q40 rsoUlrnw2IYJ6hXG6Y7wBLvuVieypskq3WjROVw2PhVww8c2rOHmfB/fzQV4VwHl OZrFzUZe79IJAWa2W87Mhsx2vDUKIInOg8jUNpqiuNK+gQXPL2wSjDOEpfBZP3jr e2uijkV7E3nDP8gXetuTGs1dN49bSnjoH5v6sHI+B/1iCnzurn6AKQhDOntoVa04 ZGkhL+PRXyIEFuHHvtUbhEHWBOS3jcrEDH/TO4gGJOCmMTIytvmm/9SNThrhuOaY zCpO86DkJ/7zHSfzqtjJi1lxRKLn6YnoO8OqDDBsRSqi3foaqFvhH6RtJMAXRUs= =kyef -----END PGP SIGNATURE----- --G4iJoqBmSsgzjUCe--