Action: PassQuick: CheckedInterface: WAN <<< Important!Direction: AnyTCP/IP Version: IP4Protocol: ICMPLog: CheckedDescription: Test ICMPGateway: default <<< Important!
ping -c1 8.8.8.8
State Type: None
Gateway: WAN_DHCP
As we can see here, only one packet - the initial ping request - matched the table, but all packets passing as the result of the state are correctly accounted for.
While it is true that a UDP communication session does not have any concept of state (an explicit start and stop of communications), this does not have any impact on PF's ability to create state for a UDP session. In the case of protocols without "start" and "end" packets, PF simply keeps track of how long it has been since a matching packet has gone through. If the timeout is reached, the state is cleared. The timeout values can be set in the options section of the pf.conf file.
...in order to have a working rule for direction "any", packets not only have to pass the firewall pipeline once, but twice (and in reverse directions).
Also, I guess you also use NAT with implicit firewall rules and implicit back-translation of incoming traffic that might get in the way of your rules.
or am I missing something?
and "strange" outgoing record with 8.8.8.8 source is not a "pretty strange" (its a new (state creating) packet, that OPN sends from WAN to the "WAN_DHCP" gateway)
But if OPNsense sends the packet from the WAN to WAN_DHCP, why the source is 8.8.8.8?
not sure what exactly can be wrong here
just check with "reply-to" disabled on "out" rules
because it received this with 8.8.8.8 source (and your WAN as a dest). its a ICMP echo reply packet(i think you can try to tcpdump this to make sure)
It is exactly inverted, I've double checked it! Also, without a gateway in the rule, there is a reply-to option in the stats. And if a gateway is set, then there is no reply-to in the stats.
There are 3 packets after a single ping
When writing firewall rules, you need to think of packets from the firewalls point of view.That's very important.Firewall rules, in general, are set again an interface, and the direction is normally IN. That's because, from the firewall's point of view, a packet going out to internet from a LAN connected device, is received (hence IN) on the firewall's LAN interface. From there the packet does through the firewall rules, NAT and then leaves (out) on the WAN interface. With stateful firewalls (and OPNsense is most certainly a stateful firewall) you only write a firewall rule for the FIRST packet.See the OPNsense documentation:https://docs.opnsense.org/manual/firewall.html
it ("reply-to effect") should be clearly visible if you look at the MAC addresses imho
imho this is exactly what I was talking about: there is no route-to and reply-to in the same rule