The Linux kernel has the ability to route traffic using nftables, iptables, and ipvs. Ive collected 3 related questions here, in order to generally ask the broader overall question of how precedence is determined with regard to kernel routing and firewalling rules:
- In general, is there an order of precedence for when these load balancing / packet filtering constructs are ordered ?
- NFT and iptables, if not managed properly from an installation perspective, can result in “collisions” (unpredictable results). The solution to this seems to be making sure iptables-legacy is installed. Is it possible to run both NFT and iptables together, and if so, what order would the given iptables “tables” (Mangle, Filter, NAT), be applied with respect to NFT tables rules ?
- IPVS is capable of implementing load balancing. In general, is it meant to occur before, or after iptables rules are applied to an incoming packet ?
- How does firewalld play into all of this?
- How does precedence work with regard to SELinux and these various rules?
For context, I recently noticed that some iptables rules on a system where NFT was installed weren’t working as expected, and , even though here are great diagrams online of how default iptables chains are ordered with regard to their resident tables, I became curious about how one would reason about these chains and their traversal if other rules from NFT, IPVS, eBPF, and so on were present.