I have installed K3s with Rancher on Rocky 9.1 machine.
According to the manual, firewalld must be turned off.
To turn off the firewalld, I performed:
systemctl disable firewalld
systemctl mask --now firewalld
I also enabled the nftables service with systemctl enable nftables
.
Now I am trying to configure a reasonable ruleset in the firewall.
As I understand, the current Linux versions use something more modern than iptables (I used to be familiar with iptables a long time ago), so I am trying to use nftables.
Here are a few questions that I need help with:
- is nftables (or the command line tool nft) the right thing to use on Rocky 9.1? Given that I am using K3s version of Kubernetes on the machine (and they produce iptables rules as well as nftables rules, which both appear in Linux), I am confused which is the "right tool" to configure on Rocky 9.1
- I have read that iptables don't support something that nftables produce, but should I care about it in my setup? Do Kubernetes or K3s have some specific compatibility requirements in regards of which kind of ruleset I create on Linux? Or can it break the network connection if I create a nft ruleset that is incompatible with iptables? What is the actual relation between nftables and iptables? Are there any other tools that do the same thing on Rocky 9.1, and should I use something even more appropriate?
EDIT:
I did some reading about nftables with subsequential debugging of my own error. Therefore I removed the 3rd part of the question which was obviously just a silly mistake. To anyone who may find it useful:
nftables drop
is a final decision after which the packet never returns. Any chain of type nat hook input
is being evaluated not only for forwarding (nat) purposes, but also for the machine itself (input). Putting policy drop
to a type nat hook input
chain and leaving the chain empty will render the machine unavailable. Even more interestingly, it will only drop the 1st packet and not the whole traffic from the machine. And that was exactly my case. I rendered the machine inaccessible, but I didn't know it, because my connection left alive until reboot. After reboot no new connections were accepted because of nat drop policy. /Hope it helps someone one day/