From owner-freebsd-pf@freebsd.org Tue Jan 23 15:51:55 2018 Return-Path: Delivered-To: freebsd-pf@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 2ADB9EB4536 for ; Tue, 23 Jan 2018 15:51:55 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.ysv.freebsd.org (mxrelay.ysv.freebsd.org [IPv6:2001:1900:2254:206a::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.ysv.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0EEA983216 for ; Tue, 23 Jan 2018 15:51:55 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.ysv.freebsd.org (Postfix) with ESMTPS id DFD2C5BB4 for ; Tue, 23 Jan 2018 15:51:54 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id w0NFpsoI075127 for ; Tue, 23 Jan 2018 15:51:54 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id w0NFpsOc075126 for freebsd-pf@FreeBSD.org; Tue, 23 Jan 2018 15:51:54 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: freebsd-pf@FreeBSD.org Subject: [Bug 193568] PF rdr rule with ipv6 does not work Date: Tue, 23 Jan 2018 15:51:54 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 9.3-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: asomers@FreeBSD.org X-Bugzilla-Status: Open X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-pf@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.created 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-pf@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "Technical discussion and general questions about packet filter \(pf\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Jan 2018 15:51:55 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D193568 --- Comment #5 from Alan Somers --- Created attachment 190002 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D190002&action= =3Dedit Fix RDR rules that redirect to ::1 "Fix" pf rdr rules with ::1 targets Redirecting an IPv6 packet to ::1 is a violation of IPv6 scoping rules, bec= ause ::1 only has node-local scope. It's supposed to be used only for traffic t= he begins and ends on a single node. Plus, it's a bad practice security-wise (server processes are often bound to ::1 as a deliberate way to prevent them from talking to the outside world), and it doesn't work on multihomed, single-fib hosts (the reply packet doesn't know which interface to use if i= ts destination is non-local). However, the same arguments apply to IPv4, and FreeBSD already has hacks to make it work there. So I'm extending those ha= cks to IPv6. Even with this "fix", rdr won't work for packets destined to a link-local (ff80::*) address, because pf doesn't know how to set the embedded scope identifier on the reply packets. A better solution would be to configure pf to only redirect a packet's port, not its address and port. However, pf doesn't currently have that capabili= ty. netinet6/ip6_input.c In ip6_input, don't reject a packet with bad scope if the firewall = has changed the destination address. ip_input does something similar w= ith the "dchg" variable. sys/netinet6/ip6_output.c In ip6_output, don't fail a packet immediately if the scope check fails. Instead, repeat the scope check after running it through the firewall, if the firewall changed either the src or dst address. ip_output simply does the scope checking after the firewall. Howev= er, ip6_output can't do that, because at that point multicast packets w= ill have inconsistent embedded scope identifiers. --=20 You are receiving this mail because: You are the assignee for the bug.=