From owner-freebsd-current@freebsd.org Mon Nov 9 13:18:38 2015 Return-Path: Delivered-To: freebsd-current@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 BC275A2A681 for ; Mon, 9 Nov 2015 13:18:38 +0000 (UTC) (envelope-from shawn.webb@hardenedbsd.org) Received: from mail-yk0-x22c.google.com (mail-yk0-x22c.google.com [IPv6:2607:f8b0:4002:c07::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7349812E9 for ; Mon, 9 Nov 2015 13:18:38 +0000 (UTC) (envelope-from shawn.webb@hardenedbsd.org) Received: by ykfs79 with SMTP id s79so34043728ykf.1 for ; Mon, 09 Nov 2015 05:18:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hardenedbsd_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:organization:user-agent :in-reply-to:references:mime-version:content-type; bh=sU8w4g0U/Cf1EbUYr6j3i16KX+/h6zCpAlq4r4Y2z3s=; b=zM/bhFEVcFklyEgp4NeriJhPGEWgeWHtmHC0B4XkmRdAu632wrBbNE6PRcSeYla6Ug 7XITVckLBDcpaoD87PgGTIwz5d6IDSP3lzDIAOahOL1JyPr1W4pCk6xuyXRs9moKpeke rAhzuNCUDEs1mbMpqSHCrHlnReJ1eviu/fT8pxIUKv8PFA1mxZmYmWQ/5ybYsK3GXbqo IJL3pqHiQkgBTjgZbuQEit4Qd4lDBfh6P+5lDQUhGN9Fmq5GsEsyLnRyQULLWMMKaTOR aUVa1vh2GbYYNZU0TchhBDARvI0lNfTdPKtHTO+pwAZnkjr1OCOHbN/SGdmaaf6W+mvi 7tQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:organization :user-agent:in-reply-to:references:mime-version:content-type; bh=sU8w4g0U/Cf1EbUYr6j3i16KX+/h6zCpAlq4r4Y2z3s=; b=kPUw1/zCAYGIHkOzokvYEdOPjDtDgrNe5VQyOZIkslUAAd2bMgTjgAZOXJDFcfDFQ+ icV4qv60pXfp5wqMUtku/7F3hARLKWvsvpTOQGSXWkm6e3Wp2rBG5KzG1xYYfLp2igwb 5LX54c5odzyLU4Q7EFD4IXRpDxaT3VxyOzBxp+mpeyGEiFwCBof2HYLwUS8CZwD13pPC GbWjCWehRNHxSal4taU435StDn1ApxJLMGY8tTmoqghZFmN5SmTi58XbPbn1/aRCb9oZ b6NOUN99vwExk6Qqd5iNguS/8Cevp5jd+r3i2Adch+1gykzo+mKUsQA4VgTxYJ6K9UqQ HJ6g== X-Gm-Message-State: ALoCoQmQ29UwGz5ZfkM7f/RIO03OOtbdKNw1qZEZXLpTiF7t6ja0M9W0IcxN4skk2dYsdgBeuyjH X-Received: by 10.129.34.131 with SMTP id i125mr24221366ywi.186.1447075117378; Mon, 09 Nov 2015 05:18:37 -0800 (PST) Received: from hbsd-dev-laptop.localnet ([129.6.251.181]) by smtp.gmail.com with ESMTPSA id q4sm14187327ywb.33.2015.11.09.05.18.36 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Nov 2015 05:18:36 -0800 (PST) From: Shawn Webb To: Kristof Provost Cc: freebsd-current@freebsd.org Subject: Re: pf NAT and VNET Jails Date: Mon, 09 Nov 2015 08:18:32 -0500 Message-ID: <5815854.WJiA8b3P58@hbsd-dev-laptop> Organization: HardenedBSD User-Agent: KMail/4.14.3 (FreeBSD/11.0-CURRENT-HBSD; KDE/4.14.3; amd64; ; ) In-Reply-To: References: <13324720.omGDCH0sVj@hbsd-dev-laptop> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart4741153.VGaV7FWRE0"; micalg="pgp-sha256"; protocol="application/pgp-signature" X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Nov 2015 13:18:38 -0000 --nextPart4741153.VGaV7FWRE0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" On Thursday, 05 November 2015 11:45:25 PM Kristof Provost wrote: > > On 05 Nov 2015, at 17:25, Shawn Webb w= rote: > > I've figured it out. I've removed all rules and went with a barebon= es > > config. > >=20 > > Right now, the laptop I'm using for NAT has an outbound interface o= f wlan0 > > with an IP of 129.6.251.181 (from DHCP). The following line works: > >=20 > > nat on wlan0 from any to any -> 129.6.251.181 > >=20 > > The following line doesn't: > >=20 > > nat on wlan0 from any to any -> (wlan0) > >=20 > > Nor does this: > >=20 > > nat on wlan0 from any to any -> wlan0 > >=20 > > From the Handbook, the lines that don't work are prefered especiall= y the > > first non-working line, since using (wlan0) would cause pf to pick = up > > wlan0's IP dynamically (which is good, since wlan0 is DHCP'd). > >=20 > > So it seems at some point of time, doing NAT dynamically broke. >=20 > So far I=E2=80=99ve had no luck reproducing this. > With pf.conf: > nat on vtnet0 from any to any -> (vtnet0) > pass in > pass out >=20 > And setup code: > ifconfig bridge0 create > ifconfig epair0 create > ifconfig epair0a up > ifconfig epair0b up > ifconfig bridge0 addm epair0a >=20 > jail -c name=3Dtest host.hostname=3Dtest vnet persist > ifconfig epair0b vnet test >=20 > ifconfig bridge0 inet 10.0.0.1/24 >=20 > jexec test ifconfig epair0b 10.0.0.2/23 > jexec test route add default 10.0.0.1 >=20 > # Activate routing > sysctl net.inet.ip.forwarding=3D1 >=20 > pfctl -e > pfctl -g -f pf.conf >=20 > Then I run exec test ping 8.8.8.8, which works as expected. >=20 > My home routing is running CURRENT, used vnet jails and also doesn=E2= =80=99t seem to > be triggering the problem. >=20 > Perhaps we=E2=80=99re still missing a component of the problem, but r= ight now I have > no idea what that would be. >=20 > Hmm. Perhaps=E2=80=A6 do you happen to know in what order things are = done during > startup? Perhaps it=E2=80=99s related to the fact that wlan0 is both = wifi and DHCP, > in the sense that pf is configured before the IP is assigned to the > interface. >=20 > Can you try reloading pf with the (wlan0) rule? (Just pfctl -g -f > /etc/pf.conf should do the trick). I'm using iocage for jailing. It's now looking like pf is back to being broken for me. I've tried eve= ry=20 combination possible, even hardcoding the values: nat on wlan0 from {192.168.6.0/24, 192.168.7.0/24} to any -> 129.6.251.= 181 pass in pass out I have zero idea why this isn't working. It seems that from the documen= tation,=20 I'm doing everything right. I can see from tcpdump that the packets are= =20 getting forwarded, but without the src IP address being rewritten to=20= 129.6.251.181. tcpdump output for a single ICMP packet, pinging to 8.8.8.8: 08:12:30.544462 IP 192.168.7.3 > 8.8.8.8: ICMP echo request, id 28131, = seq 0,=20 length 64 That src IP should say 129.6.251.181. Thanks, =2D-=20 Shawn Webb HardenedBSD GPG Key ID: 0x6A84658F52456EEE GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89 3D9E 6A84 658F 5245 6EEE --nextPart4741153.VGaV7FWRE0 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part. Content-Transfer-Encoding: 7Bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABCAAGBQJWQJ0oAAoJEGqEZY9SRW7u0hUQAMcno5u+XCm2fY3zVnyQBL/A kZ8uDoUMShjxZdbJL0saR8AONDuvTDr/C8fKMx0ir1c1ctQSFDVD4+7kvcY4RiN3 uphcCVvvCHmI9doIgVSVvqid3BvBwgtNoZUfbqZxEZeWPJxVvkcz+n97yGRUhKc9 xlim1izF9Mh5+bzD3fAiPtjF8d1p+uahU2UqZpA3ylACWi7KJyySU25CdCh1y3gs qHHtxYlF194qgJB3SN6BA7GfCm0lETJcGb9Gy01f+8MscxN7bEqnPEFW+ClHF2BK fZ8qqRl2XpFNzPrkdc3XFqij1mv97J7a0wHhW5/OLZ+nNUtq0BmDiuTYp1+/IR41 /l4mGpHOyO8wCftx5knRWsW6y8UgX2bZBKi2IhZlzLhUJAEO994Tbt6IsoHcmqAE 8u492qgjacE3AZR8VYaVrgBY10MDXIMplZNWbKhNGasnLVXxb3EqFm59n2UTaXVj 6ITKJ6BwzS4bHfjhwx07glSGojNOEHRtYwsT5qLWHD7PHqOEaKXDRKCoA2JMPXtk WpEp6gRSl1WRzOSDYy/kczMCIol7zGm3fUfuURYQG1NEncB1hk7zTQ9wSHKzDDgH n78dieg0nY+n8NnvKGJAL4EvzrSqfZ4zcvN2odCNSVzMfAQXaWLLhE7fuZek+NfY IAS3x+/EzmiKtNeK/0kM =waom -----END PGP SIGNATURE----- --nextPart4741153.VGaV7FWRE0--