Article View: bit.listserv.openbsd-pf
Article #165Re: Rule ordering changes
From: Stuart Henderson
Date: Mon, 11 Mar 2013 21:14
Date: Mon, 11 Mar 2013 21:14
62 lines
4673 bytes
4673 bytes
On 2013/03/11 12:06, Andrew Siegel wrote:
> I've been scratching my head over this one. Here is my pf.conf:
>
> int_if = "em0"
> dmz_if = "em1"
> block log all
> set skip on lo0
> block log quick inet6
> block in log quick on $int_if from ! <rfc1918> to any
> block out log quick on $int_if from any to ! <rfc1918>
> pass out log on $int_if inet proto tcp from $int_if:0 to 10.1.1.1 port ldap
> pass in log on $dmz_if inet proto tcp from $dmz_if:network to $dmz_if:0 port ldap
> pass in log on $dmz_if inet proto icmp from $dmz_if:network to $dmz_if:0
> pass out log on $dmz_if inet proto icmp from $dmz_if:0 to $dmz_if:network
> pass in log on $int_if inet proto icmp from <rfc1918> to $int_if:0
> pass out log on $int_if inet proto icmp from $int_if:0 to <rfc1918>
> pass in log on $int_if inet proto icmp from <rfc1918> to $dmz_if:network
> pass out log on $dmz_if inet proto icmp from <rfc1918> to $dmz_if:network
> pass in log on $dmz_if inet proto udp from $dmz_if:network to $dmz_if:0 port ntp
> pass in log on $int_if inet proto tcp from <rfc1918> to { $int_if:0 $dmz_if:network } port ssh
> pass out log on $dmz_if inet proto tcp from <rfc1918> to $dmz_if:network port ssh
> pass out log on $dmz_if inet proto tcp from $int_if:0 to $dmz_if:network port ssh
> pass out log on $int_if inet proto udp from $int_if:0 to <dns> port domain
> pass out log on $int_if inet proto udp from $int_if:0 to <ntp> port ntp
>
>
> The problem is that some rules end up out of order in the "pfctl -s rules" output (note the icmp rules in particular):
>
> 0 block drop log all
> 1 block drop in log quick on em0 from ! <rfc1918> to any
> 2 block drop out log quick on em0 from any to ! <rfc1918>
> 3 block drop log quick inet6 all
> 4 pass in log on em0 inet proto icmp from <rfc1918> to 192.168.7.2
> 5 pass in log on em0 inet proto icmp from <rfc1918> to 192.168.8.0/24
> 6 pass in log on em0 inet proto tcp from <rfc1918> to 192.168.7.2 port = 22 flags S/SA
> 7 pass in log on em0 inet proto tcp from <rfc1918> to 192.168.8.0/24 port = 22 flags S/SA
> 8 pass out log on em0 inet proto udp from 192.168.7.2 to <dns> port = 53
> 9 pass out log on em0 inet proto udp from 192.168.7.2 to <ntp> port = 123
> 10 pass out log on em0 inet proto tcp from 192.168.7.2 to 10.1.1.1 port = 389 flags S/SA
> 11 pass out log on em0 inet proto icmp from 192.168.7.2 to <rfc1918>
> 12 pass out log on em1 inet proto icmp from 192.168.8.1 to 192.168.8.0/24
> 13 pass out log on em1 inet proto icmp from <rfc1918> to 192.168.8.0/24
> 14 pass out log on em1 inet proto tcp from <rfc1918> to 192.168.8.0/24 port = 22 flags S/SA
> 15 pass out log on em1 inet proto tcp from 192.168.7.2 to 192.168.8.0/24 port = 22 flags S/SA
> 16 pass in log on em1 inet proto tcp from 192.168.8.0/24 to 192.168.8.1 port = 389 flags S/SA
> 17 pass in log on em1 inet proto icmp from 192.168.8.0/24 to 192.168.8.1
> 18 pass in log on em1 inet proto udp from 192.168.8.0/24 to 192.168.8.1 port = 123
>
> This is under OpenBSD 5.1. Am I misunderstanding something? Is some kind of optimization taking place behind the scenes?
>
> Andy
Yes. From man pfctl:
-o level
Control the ruleset optimizer, overriding any rule file settings.
-o none Disable the ruleset optimizer.
-o basic Enable basic ruleset optimizations. This is the
default behaviour.
-o profile Enable basic ruleset optimizations with profiling.
For further information on the ruleset optimizer, see pf.conf(5).
Technical Details
Message-ID:
<20130311194552.GT8201@symphytum.spacehopper.org>Path:
arc1-ca.pugleaf.net!jm3ni43310pbb.0!nntp.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!spln!newsgate.newsguy.com!newsp.newsguy.com!mdrnReferences:
<513E00E9.4000209@blueskystudios.com>Show Full Headers
Complete Article Headers
X-Google-Thread: ff4ef,6cb7866d2b26bce6
X-Google-NewGroupId: yes
X-Google-Attributes: gidbffa70e3,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
X-Received: by 10.68.136.104 with SMTP id pz8mr8529436pbb.3.1363036466203;
Mon, 11 Mar 2013 14:14:26 -0700 (PDT)
Path: arc1-ca.pugleaf.net!jm3ni43310pbb.0!nntp.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!spln!newsgate.newsguy.com!newsp.newsguy.com!mdrn
From: stu@spacehopper.org (Stuart Henderson)
Newsgroups: bit.listserv.openbsd-pf
Subject: Re: Rule ordering changes
Date: 11 Mar 2013 14:14:25 -0700
Organization: None
Lines: 63
Message-ID: <20130311194552.GT8201@symphytum.spacehopper.org>
References: <513E00E9.4000209@blueskystudios.com>
NNTP-Posting-Host: localhost.newsguy.com
Mime-Version: 1.0
NNTP-Posting-Date: 11 Mar 2013 21:14:25 GMT
X-Received-Bytes: 4303
Content-Type: text/plain; charset=us-ascii