Iptables – Replace default iptables with ufw rules

iptablesufw

I wanted to test removing all default iptable rules and replacing them with my own, using ufw. I have a very simple LAN that just needs 1/2 dozen ports, and iptable defaults are causing major conflicts when I try blocking IP's.

So I created the ufw rule: ufw allow 22/tcp
then I issued: echo "ufw reload" | at now + 1 min
and iptables –flush
with the expectation that my ssh session would be restored after a minute. But that didn't happen – I had to reboot the server running ufw.
Is there anything else in the default iptables that is mandatory to restore a ssh session?

Best Answer

UFW is just a tool that manipulates iptables rules. This means if you apply an UFW rule (in this case port 22) and run iptables -F after that, you will flush the rule you've just entered with UFW.

You can check your rule by doing iptables -L after applying the ufw rule.

Related Topic