From owner-freebsd-net@freebsd.org Tue May 1 13:04:50 2018 Return-Path: Delivered-To: freebsd-net@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A8BD9FAB4A1 for ; Tue, 1 May 2018 13:04:50 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from vps1.elischer.org (vps1.elischer.org [204.109.63.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "vps1.elischer.org", Issuer "CA Cert Signing Authority" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 3B6C77F434 for ; Tue, 1 May 2018 13:04:50 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from Julian-MBP3.local (220-253-154-11.dyn.iinet.net.au [220.253.154.11]) (authenticated bits=0) by vps1.elischer.org (8.15.2/8.15.2) with ESMTPSA id w41D4gZM005569 (version=TLSv1.2 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Tue, 1 May 2018 06:04:45 -0700 (PDT) (envelope-from julian@freebsd.org) Subject: Re: ipfw -- selecting locally generated packets To: Eugene Grosbein , Jeff Kletsky , freebsd-net@freebsd.org References: <979d3478-4bec-e6a1-41cd-bb26beb93123@wagsky.com> <5AE75A4E.6020907@grosbein.net> From: Julian Elischer Message-ID: <600886b2-f78d-0af7-224e-a2711f7e1106@freebsd.org> Date: Tue, 1 May 2018 21:04:36 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <5AE75A4E.6020907@grosbein.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 May 2018 13:04:50 -0000 On 1/5/18 2:02 am, Eugene Grosbein wrote: > 01.05.2018 0:48, Jeff Kletsky wrote: > >> From time to time, I rewrite my firewall rules to take advantages of the ever-improving set of features that ipfw provides. One of the challenges I have faced in the past was selecting packets that are generated on the firewall host itself, as opposed to those that it received through an interface. >> >> While I find most of the Linux firewall implementations untenable for a variety of reasons, it does provide differentiation between what they call "OUTPUT" and "FORWARD". I'm looking to see if there is a "better" way to implement this kind of selection with the 11.1 version of ipfw. >> >> "out and not in" may years ago seemed an obvious selector, and it's good to see that it is now clearly documented that it doesn't work in "man ipfw" with "(in fact, out is implemented as not in)". >> >> "not recv any" doesn't seem to be helpful either >> >> $ sudo ipfw add 64000 count ip from any to any out xmit any not recv any >> 64000 count ip from any to any out >> >> In the past, I've tagged all incoming packets and used that tag to differentiate between the two. >> >> Is there something "cleaner" (or perhaps clearer) that using a tag in that way? > I have been using "from me" for years and it works. > If you have NAT, process "from me" packets before translating outgoing packets > and process "to me" after translating incoming packet On a host with two interfaces you can use subtraction.. i.e in the outgoing part of the rules you can test on recv xxx0 and if it doesn't match it must be locally generated.  I've also used the uid rule, which can only match on local packets ut it only works if you only have a single 'user' on an appliance. > > _______________________________________________ > freebsd-net@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-net > To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org" >