A small quirk about pfSense (should be the same for other gateways): For stateful connections, the Rules matching strategy strictly follows the direction during the handshake, and thereafter all packets of this connection match the same Rules *regardless of direction*.
Things become interesting when a Rule includes advanced settings like Limiters. For example: you want to use a Limiter to restrict the download speed of a local IP (say, under pfSense's LAN subnet), and the download connection is initiated by this IP, connecting to an external server.
Then you need to set up a Rule for LAN interface (not WAN), put the IP to be limited in the Source field(!), apply the Limiter to the Out direction.
Explanation: The handshake direction is actually from this IP to the external server, so all packets of this connection apply the direction from the handshake when matching rules (source is the local IP, target is the external server). Even though the actual download packets are sent from the external server to this IP. This is somewhat counterintuitive.
Regarding the Limiter direction, it's because download packets leave pfSense heading to this IP, so it's the out direction.
Similarly, if this IP has opened a port to the external network and the connection is initiated from outside, then packets sent from outside to this IP are not subject to the Limiter restriction mentioned above, even though in both cases data is being sent from outside to this IP.
#netops