From owner-freebsd-net@freebsd.org Wed Jul 19 10:15:22 2017 Return-Path: Delivered-To: freebsd-net@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 D38ABC78900 for ; Wed, 19 Jul 2017 10:15:22 +0000 (UTC) (envelope-from bu7cher@yandex.ru) Received: from forward1o.cmail.yandex.net (forward1o.cmail.yandex.net [IPv6:2a02:6b8:0:1a72::2a1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "forwards.mail.yandex.net", Issuer "Yandex CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 735E1748E5 for ; Wed, 19 Jul 2017 10:15:22 +0000 (UTC) (envelope-from bu7cher@yandex.ru) Received: from smtp2j.mail.yandex.net (smtp2j.mail.yandex.net [95.108.130.60]) by forward1o.cmail.yandex.net (Yandex) with ESMTP id 8A5F5213FC; Wed, 19 Jul 2017 13:15:19 +0300 (MSK) Received: from smtp2j.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2j.mail.yandex.net (Yandex) with ESMTP id E2FD23EC0E6B; Wed, 19 Jul 2017 13:15:17 +0300 (MSK) Received: by smtp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id b5PUaFXIXq-FG58Nmko; Wed, 19 Jul 2017 13:15:16 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1500459316; bh=unnEaUOTkS0L+P69mHINVTUrNash5X9upbrDvMcPBV8=; h=Subject:To:References:From:Message-ID:Date:In-Reply-To; b=uCx+tBKIh9+OrvZJoahr1fPj2NcYM+QapYRJx/FUd/NZDx6GxobX1g4ydp/Yb15at 4llnJ2dGjT5yLNO/crwi9eDycbUoq0PuOd37HhmHNKc1UHn19I20FkWNyHz1Z4SVGM 6iE8htaD31vzUcRKlTLlbEM6qM3ftzXrOkLQeg/c= Authentication-Results: smtp2j.mail.yandex.net; dkim=pass header.i=@yandex.ru X-Yandex-Suid-Status: 1 0,1 0 Subject: Re: NAT before IPSEC - reply packets stuck at enc0 To: "Muenz, Michael" , freebsd-net@freebsd.org References: <459d59f7-2895-8aed-d547-be46a0fbb918@spam-fetish.org> <1c0de616-91ff-a6f9-d946-f098bc1a709f@spam-fetish.org> From: "Andrey V. Elsukov" Openpgp: id=E6591E1B41DA1516F0C9BC0001C5EA0410C8A17A Message-ID: <911903d1-f353-d5d6-d400-d86150f88136@yandex.ru> Date: Wed, 19 Jul 2017 13:12:41 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.0.1 MIME-Version: 1.0 In-Reply-To: <1c0de616-91ff-a6f9-d946-f098bc1a709f@spam-fetish.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="MDVVm9drIiXO1HjpGLti5FCXau9o8kk7i" X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Jul 2017 10:15:22 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --MDVVm9drIiXO1HjpGLti5FCXau9o8kk7i Content-Type: multipart/mixed; boundary="Oxes3KsjRvRhTVE90hXJpLbCMEhJBsmtG"; protected-headers="v1" From: "Andrey V. Elsukov" To: "Muenz, Michael" , freebsd-net@freebsd.org Message-ID: <911903d1-f353-d5d6-d400-d86150f88136@yandex.ru> Subject: Re: NAT before IPSEC - reply packets stuck at enc0 References: <459d59f7-2895-8aed-d547-be46a0fbb918@spam-fetish.org> <1c0de616-91ff-a6f9-d946-f098bc1a709f@spam-fetish.org> In-Reply-To: <1c0de616-91ff-a6f9-d946-f098bc1a709f@spam-fetish.org> --Oxes3KsjRvRhTVE90hXJpLbCMEhJBsmtG Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 19.07.2017 12:27, Muenz, Michael wrote: > Am 19.07.2017 um 10:32 schrieb Andrey V. Elsukov: >> >> What about reverse NAT rule? You need to translate decrypted packets >> back to 10.26.2.0, otherwise they will still have 10.26.1.1 IP address= >> as final destination and will not be forwarded to 10.26.2.0. >> >=20 > Hi Andrey, >=20 > I'm not really familiar with ipfw syntax, I'm more the linux guy and > there the state you be tracked. > How should I build the rules to do the reverse nat? I'm googling for 2 > days now but I only found port redirects for this. Try to add the following rule: ipfw add 179 nat 1 log all from 10.24.66.0/24 to 10.26.1.1 in recv enc0 This rule will pass a decrypted packet to the NAT instance, that will check in the states table should a packet be translated back or not. You need to have enc0 interface in UP state and sysctl variable net.enc.in.ipsec_filter_mask should be set to 1 or 2. After translation on the enc0 a packet will be returned to the IPsec subsystem, that will queue it for further processing in the netisr. Since destination address become foreign, it will be forwarded by IP stac= k. --=20 WBR, Andrey V. Elsukov --Oxes3KsjRvRhTVE90hXJpLbCMEhJBsmtG-- --MDVVm9drIiXO1HjpGLti5FCXau9o8kk7i Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEzBAEBCAAdFiEE5lkeG0HaFRbwybwAAcXqBBDIoXoFAllvMJkACgkQAcXqBBDI oXrugAgAsSTMUy6WTRfjz/6mvXPmPaSHF2mDMqA9k2O0bZozkBWNtE/y8BwrI3Nh RF2egr8M4roVP+QGDmEfQZpiQqrWRXZs87h7du7uD9LSDsLeoXUhAWQJ08fVczbI B+UGq4UeffepowLaaMRYoxDzbXu7LNZyof8klpUNZCIMbrwq/i1LD6bJWuJ1AK9Q pUYa0CIgTxsLMAFXUJ7GSir5cu0dhYSNa8qytPsqQwsJe0bzbkTKHFs/3JUW4Tf7 yqgZp27sAvJUaR2f2OoYullZqUyNbe8feyfA1hICd2PzNhnGYMo09RujORGzb7Io Xdx1mzkdrQytGnWc/W/ZAYn04/asYw== =LHSM -----END PGP SIGNATURE----- --MDVVm9drIiXO1HjpGLti5FCXau9o8kk7i--