Howdy,
I recently started using pf (FreeBSD 13.0) as my home FW with very basic rules:
Everything seems to be working fine and as expected but when I was getting familiar with "pfctl -vsr", two things caught my attention:
The first thing I noticed is that the order in which pf loaded the rules in memory is not the same as the order in the "pf.conf" file. I was wondering if this was expected behavior as I could not find a reference on this. Any pointers on this would be highly appreciated. Secondly and more importantly: I was very puzzled by rule @1 having no packets "processed" or states. From the "man pf.conf" Translations section (yes, I read the manual pages
)
When I initially configured the rules, @1-3 made perfect sense to me but I forgot the fact that once the traffic enters and is allowed by rule @3 on the internal interface (lan:bge0) it would be the immediately NATed so rule @1 would never be used. is it fair to say then that rule @1 is not needed and I can take it out? I can think of a condition that would validate it but I am just beginning to know/understand pf.
Thank you for your attention!
Ivan
I recently started using pf (FreeBSD 13.0) as my home FW with very basic rules:
Code:
lan="bge0"
wan="bge1"
set loginterface $wan
set optimization normal
set block-policy drop
set skip on lo0
scrub on $wan all
nat on $wan from $lan:network to any -> ($wan)
block drop log all
pass in on $lan from $lan:network to any keep state
pass out on $wan from $lan:network to any keep state
pass out on $wan from $wan:network to any keep state
Code:
@0 scrub on bge1 all fragment reassemble
[ Evaluations: 31084110 Packets: 15531058 Bytes: 4728288470 States: 0 ]
[ Inserted: uid 0 pid 941 State Creations: 0 ]
@0 block drop log all
[ Evaluations: 120197 Packets: 4390 Bytes: 312763 States: 0 ]
[ Inserted: uid 0 pid 941 State Creations: 0 ]
@1 pass out on bge1 inet from 192.168.128.0/24 to any flags S/SA keep state
[ Evaluations: 120197 Packets: 0 Bytes: 0 States: 0 ]
[ Inserted: uid 0 pid 941 State Creations: 0 ]
@2 pass out on bge1 inet from 172.60.28.0/18 to any flags S/SA keep state
[ Evaluations: 58165 Packets: 10747127 Bytes: 11023198233 States: 113 ]
[ Inserted: uid 0 pid 941 State Creations: 58165 ]
@3 pass in on bge0 inet from 192.168.128.0/24 to any flags S/SA keep state
[ Evaluations: 120197 Packets: 10761154 Bytes: 11025911872 States: 116 ]
[ Inserted: uid 0 pid 941 State Creations: 57642 ]

Code:
Since translation occurs before filtering the filter engine will see packets as they look after any addresses and ports have been translated.
Thank you for your attention!
Ivan