From owner-freebsd-net@freebsd.org Thu Nov 21 19:29:31 2019 Return-Path: Delivered-To: freebsd-net@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2D4C01C8AC6 for ; Thu, 21 Nov 2019 19:29:31 +0000 (UTC) (envelope-from mgrooms@shrew.net) Received: from mx2.shrew.net (mx2.shrew.net [38.97.5.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 47JqPk2h9cz3KjP for ; Thu, 21 Nov 2019 19:29:30 +0000 (UTC) (envelope-from mgrooms@shrew.net) Received: from mail.shrew.net (mail.shrew.prv [10.24.10.20]) by mx2.shrew.net (8.15.2/8.15.2) with ESMTP id xALJTS4l094250 for ; Thu, 21 Nov 2019 13:29:28 -0600 (CST) (envelope-from mgrooms@shrew.net) Received: from [10.16.32.30] (65-36-5-114.static.grandenetworks.net [65.36.5.114]) by mail.shrew.net (Postfix) with ESMTPSA id 6AC1719651E for ; Thu, 21 Nov 2019 13:29:23 -0600 (CST) From: Matthew Grooms Subject: Re: pf, stateful filter and DMZ To: freebsd-net@freebsd.org References: <20191121151041.GA93735@admin.sibptus.ru> Message-ID: <4d7b48c2-8141-e2cb-596e-8a73d9e68618@shrew.net> Date: Thu, 21 Nov 2019 13:29:13 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <20191121151041.GA93735@admin.sibptus.ru> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx2.shrew.net [10.24.10.11]); Thu, 21 Nov 2019 13:29:28 -0600 (CST) X-Rspamd-Queue-Id: 47JqPk2h9cz3KjP X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of mgrooms@shrew.net designates 38.97.5.132 as permitted sender) smtp.mailfrom=mgrooms@shrew.net X-Spamd-Result: default: False [-3.26 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+mx]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-net@freebsd.org]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; RCVD_COUNT_THREE(0.00)[3]; RCVD_TLS_LAST(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[132.5.97.38.list.dnswl.org : 127.0.10.0]; IP_SCORE(-0.96)[ip: (-9.22), ipnet: 38.0.0.0/8(2.85), asn: 174(1.64), country: US(-0.05)]; DMARC_NA(0.00)[shrew.net]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:174, ipnet:38.0.0.0/8, country:US]; MID_RHS_MATCH_FROM(0.00)[] X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Nov 2019 19:29:31 -0000 On 11/21/2019 9:10 AM, Victor Sudakov wrote: > Dear Colleagues, > > A quick question about pf from an ipfw user. > > Suppose I have three interfaces: $outside, $inside and $dmz. If I want > to block any traffic from $dmz to $inside, unless it is > > 1. Return traffic from $inside to $dmz > 2. ICMP traffic in any direction > > would these rules be sufficient? > > block in on $dmz > pass in on $dmz proto icmp > pass out on $inside Assuming a default to deny with a narrow match criteria ( using in/out & from/to ), you probably want something like the following ... # default to deny block log all # pass icmp from dmz to inside pass in  log on $if_dmz    proto icmpfrom $net_dmz to $net_inside pass out log on $if_inside proto icmp from $net_dmz to $net_inside # pass from inside to dmz pass in  log on $if_inside from $net_inside to $net_dmz pass out log on $if_dmz    from $net_inside to $net_dmz Rules will keep state by default unless you disable ( w/ no keep state ), so return packets will pass ( icmp from inside to dmz | any from dmz to inside ). You could broaden the match criteria by dropping the from/to selectors. -Matthew