Reading the pf.conf man page, and comparing a bit with OpenBSD handbook's pf description, it seems to me that:
- FreeBSD either applies the rdr or the nat rule, but not both - from manpage:
- OpenBSD has a mechanism to apply both together (to remap both the destination address and the source address)
Is there such a mechanism for FreeBSD pf?
Context: I have a (non-VNET) jail on a loopback interface (bastille0), and would like it to talk to a service on the host's lo0 interface (bound to 127.0.0.1). As I gather from https://github.com/curl/curl/issues/7160
Postscript to context: of course this is silly, rather I should move that service into a jail or otherwise reconfigure it. But I'm interested if this can be done this way for pf experience.
- FreeBSD either applies the rdr or the nat rule, but not both - from manpage:
Evaluation order of the translation rules is dependent on the type of the
translation rules and of the direction of a packet. binat rules are
always evaluated first. Then either the rdr rules are evaluated on an
inbound packet or the nat rules on an outbound packet. Rules of the same
type are evaluated in the same order in which they appear in the ruleset.
The first matching rule decides what action is taken.
- OpenBSD has a mechanism to apply both together (to remap both the destination address and the source address)
RDR-TO and NAT-TO Combination
With an additional NAT rule on the internal interface, the lacking source address translation described above can be achieved.
Is there such a mechanism for FreeBSD pf?
Context: I have a (non-VNET) jail on a loopback interface (bastille0), and would like it to talk to a service on the host's lo0 interface (bound to 127.0.0.1). As I gather from https://github.com/curl/curl/issues/7160
so accessing that bound service is not directly possible from the jail (as observation confirms). So what I do, I access a random IP $foo from the jail, and use rdr to direct $foo target to 127.0.0.1. Based on tcpdump, this seems to work, the only problem is that the bound service is (understandably) picky about connections, and forbids non-localhost sources. So, this is why I tried to NAT the request to a host-localhost IP too.
- the kernel intercepts the lookup and returns the jails own IP instead of 127.0.0.1
Postscript to context: of course this is silly, rather I should move that service into a jail or otherwise reconfigure it. But I'm interested if this can be done this way for pf experience.