From nobody Mon Feb 7 09:41:54 2022 X-Original-To: freebsd-pf@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id BB2C919BB13C for ; Mon, 7 Feb 2022 09:42:14 +0000 (UTC) (envelope-from meka@tilda.center) Received: from c3po.tilda.center (c3po.tilda.center [108.61.164.129]) (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 mx1.freebsd.org (Postfix) with ESMTPS id 4Jsh4h2Kdbz3ng3 for ; Mon, 7 Feb 2022 09:42:12 +0000 (UTC) (envelope-from meka@tilda.center) Received: from tilda.center (178-220-5-137.static.isp.telekom.rs [178.220.5.137]) by c3po.tilda.center (Postfix) with ESMTPSA id 7A73B1BFC5 for ; Mon, 7 Feb 2022 10:42:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tilda.center; s=c3po; t=1644226924; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=LZ8kl9LvaRkcC3JMxYxQW86UuSMNXB+hKYfFEmpm3tY=; b=JEE4vYeH2BU2Zy8u4kHnYJd8kjfeumXv0o7AUCnb42EFFzyN72tmWTKYRFvwTqRmn3Z7tk rfWkytVkF2sMR7yEO3VMqhyT3HiOfsll43r/ScF9OQe6blrJ11XEKAW5/+SihbAhHhJvy8 4G4vA5jDGYftcnPsRIe96zI0z4RwiNU= Date: Mon, 7 Feb 2022 10:41:54 +0100 From: Goran =?utf-8?B?TWVracSH?= To: freebsd-pf@freebsd.org Subject: IPv6 and NAT Message-ID: <20220207094154.fx23xi4i6volsqt7@tilda.center> List-Id: Technical discussion and general questions about packet filter (pf) List-Archive: https://lists.freebsd.org/archives/freebsd-pf List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-pf@freebsd.org X-BeenThere: freebsd-pf@freebsd.org MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="kn2oum6yawxi3yvw" Content-Disposition: inline X-Rspamd-Queue-Id: 4Jsh4h2Kdbz3ng3 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=fail ("headers rsa verify failed") header.d=tilda.center header.s=c3po header.b=JEE4vYeH; dmarc=pass (policy=reject) header.from=tilda.center; spf=pass (mx1.freebsd.org: domain of meka@tilda.center designates 108.61.164.129 as permitted sender) smtp.mailfrom=meka@tilda.center X-Spamd-Result: default: False [-4.83 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_SPF_ALLOW(-0.20)[+mx]; MIME_GOOD(-0.20)[multipart/signed,text/plain]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[freebsd-pf@freebsd.org]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_REJECT(0.00)[tilda.center:s=c3po]; DKIM_TRACE(0.00)[tilda.center:-]; DMARC_POLICY_ALLOW(0.00)[tilda.center,reject]; NEURAL_HAM_SHORT(-0.93)[-0.931]; DMARC_POLICY_ALLOW_WITH_FAILURES(-0.50)[]; MLMMJ_DEST(0.00)[freebsd-pf]; SIGNED_PGP(-2.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; R_MIXED_CHARSET(1.00)[subject]; ASN(0.00)[asn:20473, ipnet:108.61.164.0/22, country:US]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] X-ThisMailContainsUnwantedMimeParts: N --kn2oum6yawxi3yvw Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Hello, I'm trying to configure jails on desktop to have local addresses with the prefix of fd1a:db86:3f72:9dc4:: and NAT them using PF. What I observe is that when I try "ping -6 google.com" my router receives ICMP request from address with "fd1a:db86:3f72:9dc4::" as prefix. Inside jail (eth0 is epair): eth0: flags=8843 metric 0 mtu 1500 options=8 ether 00:a0:98:a6:60:8d hwaddr 02:1e:d3:64:68:0b inet 172.16.0.10 netmask 0xffffff00 broadcast 172.16.0.255 inet6 fe80::2a0:98ff:fea6:608d%eth0 prefixlen 64 scopeid 0x3 inet6 fd1a:db86:3f72:9dc4:2a0:98ff:fea6:608d prefixlen 64 autoconf groups: epair media: Ethernet 10Gbase-T (10Gbase-T ) status: active nd6 options=23 netstat -rn Routing tables Internet: Destination Gateway Flags Netif Expire default 172.16.0.254 UGS eth0 127.0.0.1 link#1 UH lo0 172.16.0.0/24 link#3 U eth0 172.16.0.10 link#3 UHS lo0 Internet6: Destination Gateway Flags Netif Expire ::/96 ::1 UGRS lo0 default fe80::5a9c:fcff:fe10:ff90%eth0 UG eth0 ::1 link#1 UHS lo0 ::ffff:0.0.0.0/96 ::1 UGRS lo0 fd1a:db86:3f72:9dc4::/64 link#3 U eth0 fd1a:db86:3f72:9dc4:2a0:98ff:fea6:608d link#3 UHS lo0 fe80::/10 ::1 UGRS lo0 fe80::%lo0/64 link#1 U lo0 fe80::1%lo0 link#1 UHS lo0 fe80::%eth0/64 link#3 U eth0 fe80::2a0:98ff:fea6:608d%eth0 link#3 UHS lo0 ff02::/16 ::1 UGRS lo0 On the host (cbsd0 is bridge, epair1a is host end of eth0 in the jail): ifconfig cbsd0 cbsd0: flags=8843 metric 0 mtu 1500 description: re0 ether 58:9c:fc:10:ff:90 inet 172.16.0.254 netmask 0xffffff00 broadcast 172.16.0.255 inet 172.16.1.254 netmask 0xffffff00 broadcast 172.16.1.255 inet 172.16.0.253 netmask 0xffffffff broadcast 172.16.0.253 inet6 fe80::5a9c:fcff:fe10:ff90%cbsd0 prefixlen 64 scopeid 0x3 inet6 fd10:6c79:8ae5:8b91::1 prefixlen 64 inet6 fd10:6c79:8ae5:8b91::2 prefixlen 128 id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15 maxage 20 holdcnt 6 proto rstp maxaddr 2000 timeout 1200 root id 00:00:00:00:00:00 priority 32768 ifcost 0 port 0 member: epair1a flags=143 ifmaxaddr 0 port 5 priority 128 path cost 2000 groups: bridge nd6 options=21 ifconfig re0 re0: flags=8843 metric 0 mtu 1500 options=8209b ether bc:ae:c5:e1:31:d0 inet6 fe80::beae:c5ff:fee1:31d0%re0 prefixlen 64 scopeid 0x1 inet6 2001:470:1f1a:2c6:beae:c5ff:fee1:31d0 prefixlen 64 autoconf inet 192.168.111.3 netmask 0xffffff00 broadcast 192.168.111.255 media: Ethernet autoselect (1000baseT ) status: active nd6 options=23 pfctl -sn nat on re0 inet from to any -> (re0) round-robin nat on re0 inet6 from (cbsd0:network) to any -> (re0:0) rdr-anchor "cbsd/*" on re0 all For completeness, these are my rules: # Macros and tables ext_if = "re0" # SyncThing example dhcp_ports = "{ bootps, bootpc }" tcp_ports = "{ 3000, 7681, 22000}" udp_ports = "{ 21027 }" table persist # Options set block-policy drop set skip on lo0 # Normalization scrub in all # NAT nat on $ext_if inet from to any -> ($ext_if) nat on $ext_if inet6 from (cbsd0:network) to any -> ($ext_if:0) rdr-anchor "cbsd/*" on $ext_if # Quick rules antispoof quick log for ($ext_if) # Rules block in log on $ext_if pass out pass proto tcp to any port ssh pass proto { icmp, igmp, icmp6 } pass in proto tcp from any to any port $tcp_ports pass in proto udp from any to any port $udp_ports pass in proto udp from any to any port $dhcp_ports I can see this on cbsd0 and re0 interfaces: tcpdump -n -i cbsd0 ip6 10:37:08.473385 IP6 fd1a:db86:3f72:9dc4:2a0:98ff:fea6:608d > 2a00:1450:400d:80d::200e: ICMP6, echo request, seq 0, length 16 It is what I expect, as NAT is yet to be done, but then I don't expect that source address to be visible on re0: tcpdump -n -i re0 ip6 10:38:27.580473 IP6 fd1a:db86:3f72:9dc4:2a0:98ff:fea6:608d > 2a00:1450:400d:80d::200e: ICMP6, echo request, seq 0, length 16 I am just started learning about IPv6 so if anything is obviously wrong, please point me to the docs and I'll happily RTFM. At this point I have no clue what I did wrong. Thank you, meka --kn2oum6yawxi3yvw Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEE1WIFkXy2ZeMKjjKEWj1TknovrLYFAmIA6V4ACgkQWj1Tknov rLYL3Q//fm9pzSD6ZDhcrQYxkbGhe7tJfgRA/N6IWUdxYNCyZ+81AvMqGw2oToPo z6s9RRvydA3yyem3e9QDSxKQggZwbXQ8YulnPmRQ8KM0t40XiDD54nfBcx71uSm8 keV61NVLuSW/2H3M1/zQziZv/l/swGpuO9L+auQ8cGHyFpV2pfMXJbCGNFeF73bY l84Kf4tT+arfI/FulZHoYtfRp+7VSD1/rUvJUOj1iN4fQXd7bfYqTzl1DXdm2+Vm kVSJmfR7Ukp3LV+FNPCHLex7sOzOU3kJyTyqAaP/7EdlVVKdl0melPEU1Iu6FA8/ j2spLnG+rB3ffLe2SB9Tt2Jxv6rdhzQN3sIrPBd0oPezE3OHvFraq6BAGt+e4dgT vX/afYmKObWKcRcN0WS5cVl+vxMC7E0Hhy+PlIFZwGgue/tS3DZu39/NXS/U4cWN hxjtdR+rWTnv4N8bf20FCmAoXurqszIUE3kR7tbhhc1hgQRs35hJM82m2t/MIviB WRPdfLF63NW9h7WrBfAzIuFSxvg2Icy4TqWxrfV1e+YvaYdogonYkV5GEH0MNmS6 pELnUgc2tDwoDO8RxSIJNYLwb+PG0URvNpJdczd1HNCJ/sQHvW+Jwn83bNVrIbiI vcmbEK3zXnRN2HnXD04J/l4Lc3LCqHkdkr2bz0oNUzTTnukC4b0= =VK2U -----END PGP SIGNATURE----- --kn2oum6yawxi3yvw--