Hear me out. I highly suggest you checkout UFW https://wiki.archlinux.org/title/Uncomplicated_Firewall which wraps iptables (or nftables)When you use UFW and get it working the way you want you can then go look at iptables directly and see how it's implemented.
Where is the recipe?