From owner-freebsd-net@freebsd.org Tue Jul 25 15:41:38 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 8C3C0C7F06B for ; Tue, 25 Jul 2017 15:41:38 +0000 (UTC) (envelope-from bu7cher@yandex.ru) Received: from forward3o.cmail.yandex.net (forward3o.cmail.yandex.net [IPv6:2a02:6b8:0:1a72::288]) (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 20EB380284 for ; Tue, 25 Jul 2017 15:41:37 +0000 (UTC) (envelope-from bu7cher@yandex.ru) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [5.45.198.129]) by forward3o.cmail.yandex.net (Yandex) with ESMTP id 7650520EE4; Tue, 25 Jul 2017 18:41:33 +0300 (MSK) Received: from smtp4j.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp4j.mail.yandex.net (Yandex) with ESMTP id 90C4932406D8; Tue, 25 Jul 2017 18:41:31 +0300 (MSK) Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id MVghxjkod1-fVQq8pia; Tue, 25 Jul 2017 18:41:31 +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=1500997291; bh=2SwzTR+pfDervEZfaKQU7aFki/WO8mwSm+m10RhO2sM=; h=Subject:To:References:From:Message-ID:Date:In-Reply-To; b=l1QJCdvOjEC6Cq7Sydig4fCr8Qj5G8ndVexJ9NO7RVWlSDSBpSBLVn8Hu7U1kq4Ot oT9WaojfWXfuLJkac9ro6YJ4aZnJ1c1uUZhnwd+G+nbpEbS3MNSkQ0t9P9hjtkOJKM j5CQLGnfbSvcVlUEWb5BrMz5Hc2fZ4zNt25CvHmY= Authentication-Results: smtp4j.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> <911903d1-f353-d5d6-d400-d86150f88136@yandex.ru> <2d607e1a-a2c0-0f85-1530-c478962a76cd@spam-fetish.org> <3344e189-cdf0-a2c9-3a2a-645460866f2d@yandex.ru> <1279753e-9ad1-2c02-304e-5001e2bbc82f@spam-fetish.org> <15e6eb38-ef0c-7bfd-5f2c-d2acc8ea1af4@yandex.ru> <63e80fcf-915e-2dd5-d8c9-1904c8261c6f@yandex.ru> <1c91cd8f-105d-e886-3126-67505c6c3900@spam-fetish.org> <1e889acf-49d1-b70f-7097-82e6e4dfabb6@spam-fetish.org> <454ed1b7-a80f-b096-cfa1-3c32d1e60f7d@yandex.ru> <5dfdfbb3-1046-5abe-b23a-b62c215b5d08@yandex.ru> <860b48aa-b99e-7b71-3724-587ee0a7fe80@spam-fetish.org> <1b831b84-1d3f-38cb-acee-07a339315417@yandex.ru> <0bbf5bb9-8089-f9ce-3b1d-e9bcbdbc6c76@spam-fetish.org> From: "Andrey V. Elsukov" Openpgp: id=E6591E1B41DA1516F0C9BC0001C5EA0410C8A17A Message-ID: Date: Tue, 25 Jul 2017 18:38:51 +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: <0bbf5bb9-8089-f9ce-3b1d-e9bcbdbc6c76@spam-fetish.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="UOXTRanMpkUPuc85obSMXmjMn7ps3B6tB" 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: Tue, 25 Jul 2017 15:41:38 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --UOXTRanMpkUPuc85obSMXmjMn7ps3B6tB Content-Type: multipart/mixed; boundary="La8rlHWCDGBFpEd4FhTXQGmhTlIUR1Cv4"; protected-headers="v1" From: "Andrey V. Elsukov" To: "Muenz, Michael" , freebsd-net@freebsd.org Message-ID: 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> <911903d1-f353-d5d6-d400-d86150f88136@yandex.ru> <2d607e1a-a2c0-0f85-1530-c478962a76cd@spam-fetish.org> <3344e189-cdf0-a2c9-3a2a-645460866f2d@yandex.ru> <1279753e-9ad1-2c02-304e-5001e2bbc82f@spam-fetish.org> <15e6eb38-ef0c-7bfd-5f2c-d2acc8ea1af4@yandex.ru> <63e80fcf-915e-2dd5-d8c9-1904c8261c6f@yandex.ru> <1c91cd8f-105d-e886-3126-67505c6c3900@spam-fetish.org> <1e889acf-49d1-b70f-7097-82e6e4dfabb6@spam-fetish.org> <454ed1b7-a80f-b096-cfa1-3c32d1e60f7d@yandex.ru> <5dfdfbb3-1046-5abe-b23a-b62c215b5d08@yandex.ru> <860b48aa-b99e-7b71-3724-587ee0a7fe80@spam-fetish.org> <1b831b84-1d3f-38cb-acee-07a339315417@yandex.ru> <0bbf5bb9-8089-f9ce-3b1d-e9bcbdbc6c76@spam-fetish.org> In-Reply-To: <0bbf5bb9-8089-f9ce-3b1d-e9bcbdbc6c76@spam-fetish.org> --La8rlHWCDGBFpEd4FhTXQGmhTlIUR1Cv4 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 25.07.2017 17:06, Muenz, Michael wrote: >> As I said already, the NAT thinks that both packets are inbound and do= es >> translation for source address each time. You need to do translation f= or >> both directions on enc0 interface like I described, or you need to >> somehow hack/modify ipfw_nat. >> >> You do not need to create SA for 10.26.2.0->10.24.66.0, you only need >> create security policy, that will "route" such packets into the IPsec >> tunnel. The translation will be done inside IPsec before IP >> encapsulation and encryption. Since you are using tunnel mode IPsec, >> replies will be returned to your external IP address, and this SA is >> exists already. After decryption and IP decapsulation the destination >> address of packet will be translated back to 10.26.2.N on if_enc(4). >=20 > Can I use this spdadd command also when using strongswan? (Please excus= e > stupid questions) I'm not familiar with strongswan configuration, but you can just try and check that the proposed configuration will work. >> ipfw nat 1 config ip 10.26.1.1 log >> ipfw add 179 nat 1 all from 10.26.2.0/24 to 10.24.66.0/24 out xmit enc= 0 >> ipfw add 179 nat 1 all from 10.24.66.0/24 to 10.26.1.1 in recv enc0 >> >=20 > Ok so your 3 nat commands will only match when there's a new spd like > above right? > Since there's nothing on enc0 without it. Yes, it is. A security policy will route requests from 10.26.2.0/24 into IPsec tunnel, where they should be translated, and then replies will be received. --=20 WBR, Andrey V. Elsukov --La8rlHWCDGBFpEd4FhTXQGmhTlIUR1Cv4-- --UOXTRanMpkUPuc85obSMXmjMn7ps3B6tB 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/ iQEzBAEBCAAdFiEE5lkeG0HaFRbwybwAAcXqBBDIoXoFAll3ZgsACgkQAcXqBBDI oXr3dggAwKt+Yt/s/73yQbhakUfuuUpqGkFqtfBhkWupSAxgqFd/frulKm9kcr6L DzQhdHWD6PARq/aaiJQRpaTjmjhPWeZUEoQBlrXX74kC/BAidHkPSN+W19A7jGsV CTfA4xA5tb5holOulYgRuR7591d9zIW2FL5cj8rLuLJe9FJgN2og67Tgfi5mynBO OiqkoTfNJ+TNqndRsaJNZjTURgW6PJ+xm8HmQWBGBBYLoKAklpotsOaDikb31xVp gBVa6qLqiZjTqjzfGkfaJQX2j6MdZr/D5XyixdsON9O6YaULu2/RU3e5yRqmfcW1 tGjrO83i5S5cQp3V7bFHk46tiyhBLQ== =1kw6 -----END PGP SIGNATURE----- --UOXTRanMpkUPuc85obSMXmjMn7ps3B6tB--