<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[State Filtering Question]]></title><description><![CDATA[<p dir="auto">Hello, I have a question about how pfSense (2.4.5) is filtering states when a ruleid is passed in.</p>
<p dir="auto">On the Firewall-&gt;Rules-&gt;Interface Tab, under the column 'States' there is a &lt;# of States&gt;/&lt;# of bytes&gt; &lt;KiB/MiB&gt; entry that is also a link to <code>diag_dump_states.php?ruleid=...</code></p>
<p dir="auto">I would expect the states shown to correspond to ones that were matched by the rule(s) specified in the ruleid.</p>
<p dir="auto">It seems to work on some rules but not other rules.  For example, if I click on the link in a row with a rule that just matches ICMP traffic, I see tcp states but If I click on a rule that just matches TCP/443 packets, that seems to correctly filter.  And if I click on a rule that matches only UDP/53 packets, I see tcp connections as well.</p>
<p dir="auto">It looks like the <code>pfSense_get_pf_states</code> function tries to do the filtering by matching the <code>state.rule</code> with the ruleid that was passed in.  Does every state have a rule associated with it?</p>
<p dir="auto">https://github.com/pfsense/FreeBSD-ports/blob/a9adf1491b0e981bc12a5164570b93f4d8694a94/devel/php-pfSense-module/files/pfSense.c#L3665</p>
<p dir="auto">Thank you</p>
]]></description><link>https://forum.netgate.com/topic/152832/state-filtering-question</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Apr 2026 06:46:19 GMT</lastBuildDate><atom:link href="https://forum.netgate.com/topic/152832.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 23 Apr 2020 04:29:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to State Filtering Question on Thu, 23 Apr 2020 17:23:53 GMT]]></title><description><![CDATA[<p dir="auto">mystery solved</p>
<p dir="auto">rawtaz in the irc channel suggested killing the state that referred to a rule it should not be referring to.</p>
<p dir="auto">When the state was re-established, it came up referencing the correct rule.  The most likely scenario is that when the firewall rules are changed (i.e. adding or removing rules changes the number of the rules), the already established states do not have the rule numbers updated.</p>
<p dir="auto">This is a pf 'issue' and not pfSense since pfSense reads <code>/dev/pf</code> to get the states that match a particular rule.</p>
]]></description><link>https://forum.netgate.com/post/907520</link><guid isPermaLink="true">https://forum.netgate.com/post/907520</guid><dc:creator><![CDATA[fibersnet]]></dc:creator><pubDate>Thu, 23 Apr 2020 17:23:53 GMT</pubDate></item><item><title><![CDATA[Reply to State Filtering Question on Thu, 23 Apr 2020 16:18:36 GMT]]></title><description><![CDATA[<p dir="auto">Here is another example with some more debug info:</p>
<p dir="auto">I created a permit rule in pfSense to allow NTP traffic on 123/UDP.<br />
pfSense creates a link in the States column: <code>diag_dump_states.php?ruleid=122</code></p>
<p dir="auto">I click on it and see tcp traffic there which of course is unexpected.</p>
<p dir="auto">Now to verify this:</p>
<pre><code>$ pfctl -vvsr | grep -A3 '@122'
@122(1544378750) pass in quick on igb0.20 inet proto udp from 10.1.20.0/24 to 10.1.20.1 port = ntp keep state label "USER_RULE: allow pfSense services"
  [ Evaluations: 271440    Packets: 137       Bytes: 12710       States: 1     ]
  [ Inserted: pid 34596 State Creations: 27    ]
</code></pre>
<p dir="auto">And now lets look at the state table, I don't understand why there is TCP traffic that is labeled with <code>rule 122</code></p>
<pre><code>$ pfctl -vvss | grep -B2 -A1 'rule 122'
igb0.20 tcp 172.217.7.14:443 &lt;- 10.1.20.60:57309       ESTABLISHED:ESTABLISHED
   [1344343563 + 55723] wscale 8  [55088501 + 268800] wscale 7
   age 17:04:30, expires in 103:27:58, 239:237 pkts, 109178:80245 bytes, rule 122
   id: 010000005e9f003e creatorid: ef6de259
--
igb0.20 tcp 172.253.63.188:5228 &lt;- 10.1.20.101:49961       ESTABLISHED:ESTABLISHED
   [1573218077 + 42304] wscale 8  [3525452166 + 64768] wscale 6
   age 31:43:08, expires in 111:24:22, 1965:1974 pkts, 104738:118461 bytes, rule 122
   id: 010000005e9e8202 creatorid: ef6de259
--
igb0.20 tcp 172.253.122.188:5228 &lt;- 10.1.20.107:49308       ESTABLISHED:ESTABLISHED
   [952469950 + 445440] wscale 8  [3218978541 + 64768] wscale 8
   age 18:49:36, expires in 118:51:20, 446:458 pkts, 31266:130786 bytes, rule 122
   id: 020000005e9f0771 creatorid: ef6de259
--
</code></pre>
<p dir="auto">Perhaps my understanding of the <code>rule 122</code> is incorrect, but is it valid key to use to identify which rule allowed a particular state?</p>
]]></description><link>https://forum.netgate.com/post/907501</link><guid isPermaLink="true">https://forum.netgate.com/post/907501</guid><dc:creator><![CDATA[fibersnet]]></dc:creator><pubDate>Thu, 23 Apr 2020 16:18:36 GMT</pubDate></item><item><title><![CDATA[Reply to State Filtering Question on Thu, 23 Apr 2020 14:08:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/fibersnet">@<bdi>fibersnet</bdi></a> said in <a href="/post/907419">State Filtering Question</a>:</p>
<blockquote>
<p dir="auto">Source -&gt; Destination: 10.1.10.107:58362 -&gt; 141.207.151.233:4500</p>
</blockquote>
<p dir="auto">Very special animal.<br />
IPSec .... NAT traversal ...</p>
<p dir="auto">I'll block that one and see what happens - I do not IPSEC ....</p>
]]></description><link>https://forum.netgate.com/post/907449</link><guid isPermaLink="true">https://forum.netgate.com/post/907449</guid><dc:creator><![CDATA[Gertjan]]></dc:creator><pubDate>Thu, 23 Apr 2020 14:08:29 GMT</pubDate></item><item><title><![CDATA[Reply to State Filtering Question on Thu, 23 Apr 2020 13:15:28 GMT]]></title><description><![CDATA[<p dir="auto">From reading the pf docs, pf can keep state about icmp packets (as well as UDP packets which are stateless)</p>
<p dir="auto">Thanks for the tip on filtering DNS on UDP/53, but rest assured I was not filtering, I had a permit rule just to do some logging.</p>
<p dir="auto">That is actually how I ran into this issue.<br />
How to reproduce:</p>
<p dir="auto">Create a permit rule on an interface:<br />
Action: Pass<br />
Address Family: IPv4<br />
Protocol: TCP/UDP<br />
Source: network for that interface<br />
Destination: address of the interface<br />
Destination Port Range: 53, 67, 123</p>
<p dir="auto">After some time, I click on the link that shows me the states: <code>https://10.1.10.1/diag_dump_states.php?ruleid=114,115,116,117,118,119</code></p>
<p dir="auto">I'm guessing there are 6 rules because, 3 (ports) * 2 (tcp and udp)</p>
<p dir="auto">As expected I see entries like:</p>
<p dir="auto">Protocol: udp<br />
Source -&gt; Destination: 10.1.10.106:52707 -&gt; 10.1.10.1:53<br />
State: SINGLE:MULTIPLE<br />
Packets: 1/1<br />
Bytes 88B / 131B</p>
<p dir="auto">But unexpectedly I see entries like:</p>
<p dir="auto">Protocol: udp<br />
Source -&gt; Destination: 10.1.10.107:58362 -&gt; 141.207.151.233:4500<br />
State: MULTIPLE:MULTIPLE<br />
Packets: 27.146K / 38.017 K<br />
Bytes: 3.9 MiB / 5.78 MiB</p>
<p dir="auto">The Destination isn't even the address of the interface, (its some verizon one), and the destination port isn't in 53, 67, 123 (its 4500).</p>
<p dir="auto">So I am curious why that entry is showing up when it should not be associated with that permit rule.</p>
]]></description><link>https://forum.netgate.com/post/907419</link><guid isPermaLink="true">https://forum.netgate.com/post/907419</guid><dc:creator><![CDATA[fibersnet]]></dc:creator><pubDate>Thu, 23 Apr 2020 13:15:28 GMT</pubDate></item><item><title><![CDATA[Reply to State Filtering Question on Thu, 23 Apr 2020 05:42:11 GMT]]></title><description><![CDATA[<p dir="auto">ICMP traffic uses states ?<br />
It's just one packet send out, and one packet comes back. The state is done.</p>
<p dir="auto">( this is me thinking out loud - setting up an entire SYNC ACK etc session would be overkill for ICMP )</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/fibersnet">@<bdi>fibersnet</bdi></a> said in <a href="/post/907359">State Filtering Question</a>:</p>
<blockquote>
<p dir="auto">And if I click on a rule that matches only UDP/53 packets</p>
</blockquote>
<p dir="auto">Not related, but keep in mind that DNS answers can be to big for UDP. TCP will be used then.<br />
I guess another connection would be used for this.<br />
Filtering DNS traffic using only UDP/53 can break your DNS.</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/fibersnet">@<bdi>fibersnet</bdi></a> said in <a href="/post/907359">State Filtering Question</a>:</p>
<blockquote>
<p dir="auto">Does every state have a rule associated with it?</p>
</blockquote>
<p dir="auto">A state is created if a initially unknown packet comes into an interface, and matches a rule.<br />
A subsequent packets of the same "data stream" will match this uniquely constructed state, no more need to parse the entire firewall rule set again. That's what a state-base firewall is all about.</p>
]]></description><link>https://forum.netgate.com/post/907362</link><guid isPermaLink="true">https://forum.netgate.com/post/907362</guid><dc:creator><![CDATA[Gertjan]]></dc:creator><pubDate>Thu, 23 Apr 2020 05:42:11 GMT</pubDate></item></channel></rss>