I would like to set up a simple forward rule (not port forward!) on FreeBSD 12.3 that filters based on received-on interface and going-out-on interface. IP networks should not be part of the rule as it acts like a router for all kind of IPs. The routed networks will be set dynamically by a routing daemon (BIRD with OSPF).
In FreeBSD using PF I can only set one ifspec per filter rule ([ "on" ifspec ]) as per man 5 pf.conf:
pf-rule = action [ ( "in" | "out" ) ] [ "log" [ "(" logopts ")"] ] [ "quick" ] [ "on" ifspec ] [ route ] [ af ] [ protospec ] hosts [ filteropt-list ] I would like the combination of both input-interface and output-interface to match. How can I do that?
In Linux using nft/nftables I would do this:
define iface_site2site = { "tun0", "tun1", "tun9" } [...] chain forward { type filter hook forward priority 0; policy drop; iifname $iface_site2site oifname $iface_site2site accept \ comment "Freely forward packets between site-to-site links, firewalled at final destination." } [...] In Linux using iptables I would do this:
iptables -A [...] --in-interface tun+ --out-interface tun+ -j ACCEPT How can I do the above on FreeBSD?
Just to be clear; I'm NOT looking for port forwarding or NAT rules.
quick). Mayby your scenario can be served by a simpleroute-tointerface. If you want the explicit AND which you imply then I would look into tag/tagged (aka policy filtering). Do your filter onpass in on $tunand set a tag. Thenpass out on $tunand check for the tag.