From owner-freebsd-ipfw@freebsd.org Tue Jul 28 06:50:02 2015 Return-Path: Delivered-To: freebsd-ipfw@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 3315D9ACC62 for ; Tue, 28 Jul 2015 06:50:02 +0000 (UTC) (envelope-from bycn82@gmail.com) Received: from mail-vn0-x22f.google.com (mail-vn0-x22f.google.com [IPv6:2607:f8b0:400c:c0f::22f]) (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 E250ED3A; Tue, 28 Jul 2015 06:50:01 +0000 (UTC) (envelope-from bycn82@gmail.com) Received: by vnds125 with SMTP id s125so39510240vnd.1; Mon, 27 Jul 2015 23:50:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=NJCHuFKkV+OWbGd7rPvz1owaiKatulMkAsCFPjAdEV0=; b=HSwcarDjB792kuHnbymAS4lrEZSgqrMRSob4U+Ru+TKjFQIKN61nVnRZTgXlRWY7lG 7Z4Aso6XzrsTLqtvmBYDkcVUmpqkIt2LTEsIkbtIzA7UQKtfCwZvgt+ZA18C6R2LFj4z L7Cn7knuutNRjgJ5nG3SvKkLk6LeaMuLnxvmo1n7QhYBQvD9vzP1y8dbWYnqwHJWalTV vYar7uVzCBaDjWfxPqLziaRfv0SZG1qtMPp0rnRMbxvex9hs/gPgmAdppDp60Xcbzbwa qGYmZTXIzRzj4lFDr2D60LVOaLDa60F/OvS59urtTBKYGul8/xyVvGQ94Tt8J3jqDV/6 4MIA== MIME-Version: 1.0 X-Received: by 10.52.252.74 with SMTP id zq10mr40413976vdc.18.1438066200555; Mon, 27 Jul 2015 23:50:00 -0700 (PDT) Received: by 10.31.174.6 with HTTP; Mon, 27 Jul 2015 23:50:00 -0700 (PDT) In-Reply-To: <20150728150845.V17327@sola.nimnet.asn.au> References: <1435692039.18121.12.camel@yahoo.com> <5594395D.6050103@FreeBSD.org> <20150728150845.V17327@sola.nimnet.asn.au> Date: Tue, 28 Jul 2015 14:50:00 +0800 Message-ID: Subject: Re: keep-state and in-kernel NAT exposes local ip on external interface From: bycn82 To: Ian Smith Cc: Lev Serebryakov , "freebsd-ipfw@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: freebsd-ipfw@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: IPFW Technical Discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Jul 2015 06:50:02 -0000 for me. i am totally dont understand all these. waiting dor example as well On Tuesday, July 28, 2015, Ian Smith wrote: > Way back on Wed, 1 Jul 2015 22:02:53 +0300, Lev Serebryakov wrote: > > On 30.06.2015 22:20, Georgios Amanakis via freebsd-ipfw wrote: > > > > It is good example for my changes :) All this "skipto / keep-state" > > magic is not understandable. > > Indeed. So all we're waiting for, Lev, is some simple usage examples of > how things should be done with your new stateful operators, especially > when combining stateful rules with NAT. Please see what you can do .. > > I know it's clear to you, but I for one cannot get my head around these > without a couple of examples, roughly suitable for inclusion in ipfw(8) > EXAMPLES section. Rough illustrations would do fine at first. > > In the problems shown lately, including the one below (harder to read > with the quoting wrapped like that!) it seems the problem of keepalives > being issued using the internal address would not occur if keep-state > was only applied _after_ NAT, only on the already-translated source > address, but like you and apparently many others, I find these rulesets > very difficult to follow in terms of different possible flows. > > cheers, Ian > > > > On FreeBSD 10.1p13 with two interfaces em0(internet) and em1(lan) I > > > can fish (tcpdump)packets on em0 which have escaped the in-kernel > > > NAT and have as source address an IP on the LAN. > > > > > > This should not happen and I can confirm that with pf this is not > > > the case. I have the following ipfw rules: > > > > > > nat: ipfw nat 123 config ip xxx.xxx.xxx.xxx same_ports reset > > > > > > 00100 reass ip from any to any in 00200 allow ip from any to any > > > via lo0 00300 allow ip from any to any via em1 00400 nat 123 ip > > > from any to any in recv em0 00500 check-state 00600 skipto 24000 ip > > > from any to me dst-port 80,443,22,500,4500,1194,993,8112 in recv > > > em0 keep-state 00700 skipto 24000 ip from any to any out xmit em0 > > > keep-state 00800 deny log ip from any to any 24000 nat 123 ip from > > > any to any out xmit em0 24100 allow ip from any to any > > > > > > Contrary to many online tutorials, including the example of the > > > handbook regarding NAT ( > > > https://www.freebsd.org/doc/handbook/firewalls-ipfw.html), when > > > one places the NAT rules with the opposite order (i.e. outbound > > > rule first and then the inbound rule) the problem disappears. > > > > > > i.e. ... 00400 nat 123 ip from any to any out xmit em0 ... 24000 > > > nat 123 ip from any to any in recv em0 ... > > > > > > Why is this happening? Any objections to reversing the order of the > > > NAT rules? > > > - -- > > // Lev Serebryakov > _______________________________________________ > freebsd-ipfw@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-ipfw > To unsubscribe, send any mail to "freebsd-ipfw-unsubscribe@freebsd.org > " >