From owner-freebsd-net@freebsd.org Wed Aug 5 13:52:39 2020 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 AC230377189 for ; Wed, 5 Aug 2020 13:52:39 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.nyi.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id 4BMCjz4BZWz4rpS for ; Wed, 5 Aug 2020 13:52:39 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.nyi.freebsd.org (Postfix) id 8FE25376FA8; Wed, 5 Aug 2020 13:52:39 +0000 (UTC) Delivered-To: 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 8FA83377188 for ; Wed, 5 Aug 2020 13:52:39 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BMCjz3M2yz4rXn for ; Wed, 5 Aug 2020 13:52:39 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 56A621719A for ; Wed, 5 Aug 2020 13:52:39 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 075DqdME067795 for ; Wed, 5 Aug 2020 13:52:39 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 075Dqdga067793 for net@FreeBSD.org; Wed, 5 Aug 2020 13:52:39 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: net@FreeBSD.org Subject: [Bug 248474] NAT broken on IPsec/VTI [if_ipsec] Date: Wed, 05 Aug 2020 13:52:38 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: misc X-Bugzilla-Version: Unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: m.muenz@gmail.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: net@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.33 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, 05 Aug 2020 13:52:39 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D248474 Michael Muenz changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |m.muenz@gmail.com --- Comment #8 from Michael Muenz --- Hi, I just set up a test tunnel between two OPNsense 20.7 (12.1). Site-A (10.10.12.0/2) - FW-A --- FW-B - Site-B (10.10.10.0/24) Ping without NAT from A to B is no problem. When I set a nat rule (pf of course) on interface ipsec4000 so source address should be 192.168.199.1 instead of 10.10.12.0, I can see the packet correctly translated in ipsec40= 00 and enc0, but no ESP packet going to WAN of FW-B, so there seem to be a mis= sing hook somewhere. TCPDUMP on LAN FW-A: root@PB-FW1-KARL:~ # tcpdump -n -i vtnet1 icmp tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on vtnet1, link-type EN10MB (Ethernet), capture size 262144 bytes 15:32:22.768297 IP 10.10.12.51 > 10.10.10.1: ICMP echo request, id 18103, s= eq 26, length 64 15:32:23.840814 IP 10.10.12.51 > 10.10.10.1: ICMP echo request, id 18103, s= eq 27, length 64 15:32:24.913369 IP 10.10.12.51 > 10.10.10.1: ICMP echo request, id 18103, s= eq 28, length 64 TCPDUMP on ipsec4000 FW-A: root@PB-FW1-KARL:~ # tcpdump -n icmp -i ipsec4000 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on ipsec4000, link-type NULL (BSD loopback), capture size 262144 bytes 15:32:49.288388 IP 192.168.199.1 > 10.10.10.1: ICMP echo request, id 4355, = seq 51, length 64 15:32:50.350974 IP 192.168.199.1 > 10.10.10.1: ICMP echo request, id 4355, = seq 52, length 64 15:32:51.423561 IP 192.168.199.1 > 10.10.10.1: ICMP echo request, id 4355, = seq 53, length 64 TCPDUMP on enc0 FW-A: root@PB-FW1-KARL:~ # tcpdump -n icmp -i enc0 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on enc0, link-type ENC (OpenBSD encapsulated IP), capture size 26= 2144 bytes 15:32:38.737241 (authentic,confidential): SPI 0xc520971a: IP 192.168.199.1 > 10.10.10.1: ICMP echo request, id 4355, seq 41, length 64 15:32:39.752371 (authentic,confidential): SPI 0xc520971a: IP 192.168.199.1 > 10.10.10.1: ICMP echo request, id 4355, seq 42, length 64 15:32:40.824808 (authentic,confidential): SPI 0xc520971a: IP 192.168.199.1 > 10.10.10.1: ICMP echo request, id 4355, seq 43, length 64 Also pf seems to work correctly: root@PB-FW1-KARL:~ # pfctl -s all | grep 10.10.10. nat on ipsec4000 inet proto icmp from any to 10.10.10.0/24 -> 192.168.199.1 port 1024:65535 all icmp 10.10.10.1:24247 <- 10.10.12.51:24247 0:0 all icmp 192.168.199.1:25905 (10.10.12.51:24247) -> 10.10.10.1:25905 = 0:0 Setting nat on enc0 will just be ignored: root@PB-FW1-KARL:~ # pfctl -s all | grep 10.10.10. nat on enc0 inet proto icmp from any to 10.10.10.0/24 -> 192.168.199.1 port 1024:65535 all icmp 10.10.10.1:26295 <- 10.10.12.51:26295 0:0 all icmp 10.10.12.51:26295 -> 10.10.10.1:26295 0:0 It seems Andrey (Hi, we were in touch about VTI and OPNsense around 2 years ago) is right, I loaded ipfw and ipfw_nat in OPNsense and did: ipfw nat 123 config ip 192.168.199.1 ipfw add 124 nat 123 ip4 from 10.10.12.0/24 to 10.10.10.0/24 out After this I can see packets on Site-B coming from 192.168.199.1, but not reply, but this seems just to be another missing ipfw rule.=20 So for OPNsense I don't see a quick fix, maybe we can try patch from Eugene= if it really has a chance to go in upstream :) Best, Michael --=20 You are receiving this mail because: You are the assignee for the bug.=