From owner-freebsd-questions@freebsd.org Sat May 1 14:37:44 2021 Return-Path: Delivered-To: freebsd-questions@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 5853362D72D for ; Sat, 1 May 2021 14:37:44 +0000 (UTC) (envelope-from paul@gromit.dlib.vt.edu) Received: from gromit.dlib.vt.edu (gromit.dlib.vt.edu [128.173.49.70]) (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 (2048 bits) client-digest SHA256) (Client CN "gromit.dlib.vt.edu", Issuer "Chumby Certificate Authority" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FXWzq46DQz4brc for ; Sat, 1 May 2021 14:37:43 +0000 (UTC) (envelope-from paul@gromit.dlib.vt.edu) Received: from smtpclient.apple (unknown [73.99.214.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gromit.dlib.vt.edu (Postfix) with ESMTPSA id B929C32E; Sat, 1 May 2021 10:37:42 -0400 (EDT) From: Paul Mather Message-Id: <90DCF979-C3AE-4775-BE39-DB3F455F7D4E@gromit.dlib.vt.edu> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.80.0.2.43\)) Subject: Re: PF with IPv6 Date: Sat, 1 May 2021 10:37:42 -0400 In-Reply-To: To: freebsd-questions@freebsd.org References: X-Mailer: Apple Mail (2.3654.80.0.2.43) X-Rspamd-Queue-Id: 4FXWzq46DQz4brc X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=vt.edu (policy=none); spf=none (mx1.freebsd.org: domain of paul@gromit.dlib.vt.edu has no SPF policy when checking 128.173.49.70) smtp.mailfrom=paul@gromit.dlib.vt.edu X-Spamd-Result: default: False [-2.47 / 15.00]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FREEFALL_USER(0.00)[paul]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MV_CASE(0.50)[]; MID_RHS_MATCH_FROM(0.00)[]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; ARC_NA(0.00)[]; SPAMHAUS_ZRD(0.00)[128.173.49.70:from:127.0.2.255]; RECEIVED_SPAMHAUS_PBL(0.00)[73.99.214.146:received]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RBL_DBL_DONT_QUERY_IPS(0.00)[128.173.49.70:from]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_HAM_SHORT(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-0.97)[-0.966]; R_SPF_NA(0.00)[no SPF record]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:1312, ipnet:128.173.0.0/16, country:US]; RCVD_COUNT_TWO(0.00)[2]; MAILMAN_DEST(0.00)[freebsd-questions]; DMARC_POLICY_SOFTFAIL(0.10)[vt.edu : No valid SPF, No valid DKIM,none] Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.34 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 May 2021 14:37:44 -0000 On Fri, 30 Apr 2021 21:20:48 -0700, Doug Hardie > wrote: > Message: 3 > Date: Fri, 30 Apr 2021 21:20:48 -0700 > From: Doug Hardie > > To: FreeBSD Questions > > Subject: PF with IPv6 > Message-ID: <2CD4806C-F1A4-4DDE-8C2F-2B0A08EA2A18@sermon-archive.info = > > Content-Type: text/plain; charset=3Dus-ascii >=20 > FreeBSD 13-RELEASE. I have a small test network setup and tried to = block all IPv6 except those addressed to a specific address. = /etc/pf.conf contained: >=20 > ext_if =3D "bge0" > LAN3 =3D "2001:1000:0:3000::/64" > pass in quick log on $ext_if proto ipv6 from $LAN3 to $LAN3 > block in log on $ext_if proto ipv6 from any to any >=20 > Nothing got blocked. pftop showed all zeros for both rules. I then = added at the end: >=20 > pass in quick log on $ext_if proto icmp6 from $LAN3 to $LAN3 > block in log on $ext_if proto icmp6 from any to any >=20 > A lot of stuff got blocked. The log shows many entries like: >=20 > 15:59:41.597632 rule 3/0(match): block in on bge0: (hlim 1, = next-header Options (0) payload length: 32) fe80::120c:6bff:fe5d:4404 > = ff02::1: HBH (rtalert: 0x0000) (pad1)(pad1) ICMP6, multicast listener = query > 0x0000: 6000 0000 0020 0001 fe80 0000 0000 0000 = `............... > 0x0010: 120c 6bff fe5d 4404 ff02 0000 0000 0000 = ..k..]D......... > 0x0020: 0000 0000 0000 0001 3a00 0502 0000 0000 = ........:....... > 0x0030: 8200 98aa .... >=20 > Rule 3 is the block for ICMP6, but those are clearly IP6 packets that = should have been blocked by rule 1. Is there a problem with IPv6 and pf? It's not clear to me precisely what you are trying to achieve. The = "proto" keyword in PF rules refers to protocols in /etc/protocols. Your = rules appear to be targeting the specific case of filtering IPv6 = encapsulated in IPv4. I don't believe that is what you intend. The more standard way in PF to block IPv6 vs IPv4 traffic is to use = "inet" (IPv4) or "inet6" (IPv6) to target IPv4 or IPv6 packets. Note, the last rule you added that you say did start blocking things is = more typical of rules to block ICMP6. Because you omit "inet" or = "inet6" on the rule it will be applied to both IPv4 and IPv6 packets. = But, the "proto icmp6" part is specifically targeting ICMP6. So, to summarise, use "inet" and "inet6" to select IPv4 and IPv6 and = "proto" to select the protocol you want to target (e.g., "tcp", "udp", = "icmp", "icmp6", etc.). E.g., "pass in log quick on $ext_if inet6 from = ..." to allow all IPv6 for the rule, or ""pass in log quick on $ext_if = inet6 proto tcp from ..." to allow only IPv6 TCP traffic, etc. Cheers, Paul.=