I am doing dynamic, short-lived UDP port forwarding based on source address to destination port tuples. This works fine using nftables with maps, lookups and appropriate rules (nat in a prerouting / nat dest chain and masq in postrouting / nat src chain).
However: when using NAT in nftables no rule lookup happens for follow up (established?) packets in a flow (see documentation). This means I cannot kill existing flow by dropping elements from a map and / or adding a filtering rule on maps.
I think the easiest way to handle this is to do stateless NAT. However a simple rule in a prerouting filter chain with priority raw like the following one (not using maps but variables to simplify the example) does not seem to work. I see the trace but no packets arrive at $target.
ip saddr $client ip protocol udp notrack ip daddr set $target nftrace set 1 return Is there some documentation on how to build stateless NAT for nftables in detail that I'm missing? Do I need to add rules for the flow from $target back to $client as well?
Or is there a way to filter existing NAT flows that I'm not aware off, e.g. by adding aggressive connection tracking timeouts (not really sure if CT applies to NAT via nftables as well)?