From owner-freebsd-pf@FreeBSD.ORG Thu Dec 6 02:15:52 2012 Return-Path: Delivered-To: freebsd-pf@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7EAFDB6C; Thu, 6 Dec 2012 02:15:52 +0000 (UTC) (envelope-from peter@aoeu.ca) Received: from homiemail-a57.g.dreamhost.com (caibbdcaaaaf.dreamhost.com [208.113.200.5]) by mx1.freebsd.org (Postfix) with ESMTP id 40E988FC0C; Thu, 6 Dec 2012 02:15:51 +0000 (UTC) Received: from homiemail-a57.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a57.g.dreamhost.com (Postfix) with ESMTP id 8B795208076; Wed, 5 Dec 2012 18:15:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=aoeu.ca; h=mime-version :in-reply-to:references:date:message-id:subject:from:to:cc: content-type; s=aoeu.ca; bh=i83sZb6itjNrG4OqSx/8z4qwCPs=; b=p5EZ YnuNSrAMYZb8V9eqdlRdN3Ztbkm851pZyu9MHznSrxaXBegTtNpRMLxfbCYTqawU o978t5xQ8b78WjfF7hkYlE8SZlujRkVc0hmYnu04dJPw9T1yy2z8/bMi7H+t5tjK vUIqneXTHPcTC+j57A6u6DcaN3AgSpADIaH5Tk4= Received: from mail-pa0-f54.google.com (mail-pa0-f54.google.com [209.85.220.54]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: peter@aoeu.ca) by homiemail-a57.g.dreamhost.com (Postfix) with ESMTPSA id 5CE73208070; Wed, 5 Dec 2012 18:15:48 -0800 (PST) Received: by mail-pa0-f54.google.com with SMTP id bi5so4130680pad.13 for ; Wed, 05 Dec 2012 18:15:50 -0800 (PST) MIME-Version: 1.0 Received: by 10.68.191.104 with SMTP id gx8mr1488184pbc.138.1354760150862; Wed, 05 Dec 2012 18:15:50 -0800 (PST) Received: by 10.68.247.105 with HTTP; Wed, 5 Dec 2012 18:15:50 -0800 (PST) In-Reply-To: References: <20121119235601.GK2692@verio.net> Date: Wed, 5 Dec 2012 21:15:50 -0500 Message-ID: Subject: Re: Routing return NAT traffic based on interface From: Peter McAlpine To: =?ISO-8859-1?Q?Ermal_Lu=E7i?= Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: fox@verio.net, "freebsd-pf@freebsd.org" X-BeenThere: freebsd-pf@freebsd.org X-Mailman-Version: 2.1.14 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: Thu, 06 Dec 2012 02:15:52 -0000 Ermal this looks to be working perfectly. Thank you so much! -Peter On Wed, Dec 5, 2012 at 10:21 AM, Ermal Lu=E7i wrote: > > > > On Wed, Dec 5, 2012 at 3:51 PM, Peter McAlpine wrote: > >> First off, thanks for all the suggestions from both of you. My email >> filters were messed up causing me to miss your replies. >> >> On 19 November 2012 18:56, David DeSimone wrote: >> > If I understand the poster's problem, it is that there could be whole >> > worlds of other networks behind $int_if, and he is not able to predict >> > what IP addresses should be used to match that traffic; in fact, it is >> > merely the fact that the traffic is arriving on $int_if that indicates >> > it shoudl be NAT'd. >> ^^ this is the problem exactly. >> >> Here's the config I have: >> tun_if =3D "tap3" >> ext_if =3D "xn0" >> set skip on lo >> nat on $ext_if from !$ext_if:network to any -> $ext_if >> pass in on $tun_if from $tun_if:network to any keep state >> pass out on $ext_if from any to any keep state >> > > Maybe this can help, by writing the rules as follows. > > pass in on $tun_if from any to any tag TUNIFACE keep state > pass in on $ext_if route-to ($tun_if $gateway_tun_if) from any to !self > tag TUNIFACE keep state > > pass out on $tun_if reply-to ($ext_if $ext_if_gateway) from any to any > tagged TUNIFACE keep state > pass out on $ext_if reply-to ($tun_if $gateway_tun_if) from any to any > tagged TUNIFACE keep state > > Then keep your other rules going... > > >> I've attached a simple network diagram. If I ping google.com from a.b.c.= d >> the icmp traffic on 'server' goes out ext_if NAT'd, then comes back from >> google.com, but then 'server' is trying to send it back out ext_if again >> because 'server''s default route is the Internet. >> >> I can get the return traffic to go down the tunnel by manually adding a >> route on 'server' to send traffic for a.b.c.0/24 down the tunnel, but th= en >> I need to be aware of what all the networks behind 'client' are, and I >> don't want to have to do that. >> >> Thanks again for all the ideas/input! >> -Peter >> >> On Mon, Nov 19, 2012 at 7:46 PM, Kevin Wilcox > >wrote: >> >> > On 19 November 2012 18:56, David DeSimone wrote: >> > >> > > This doesn't seem right, because even traffic coming in via the >> external >> > > interface will have its target IP changed to be the router, even if >> > > it is destined for some other place. Previously you were using "fro= m >> > > $int_if:network" to prevent this from happening to other traffic, bu= t >> > > without that restriction, every packet would be subject to NAT. >> > >> > My assumption was that the traffic coming in on the external interface >> > is already destined for the outside IP of the router, unless he's >> > doing some really funky stuff on both sides ;) >> > >> > It sounded like he wanted to NAT anything coming from the inside >> > interface and then anything on the outside that wasn't return NAT >> > traffic was supposed to terminate on the router, but I've been known >> > to have clogged ears and awfully poor eyesight. >> > >> > kmw >> > >> >> _______________________________________________ >> freebsd-pf@freebsd.org mailing list >> http://lists.freebsd.org/mailman/listinfo/freebsd-pf >> To unsubscribe, send any mail to "freebsd-pf-unsubscribe@freebsd.org" >> >> > > > -- > Ermal >