I’ve tried multiple times but still can’t figure out why I can’t save iptables rules permanently.
My understanding is that we save iptables rules with:
sudo iptables-save > /etc/iptables.rules
I created an iptables.rules
file inside the /etc
directory. Even after giving full permissions (sudo chmod a+rwx /etc/iptables.rules
), I still get a “permission denied” error when trying to append rules to /etc/iptables.rules
.
As a workaround, I created separate rule files inside each user’s home directory, saved iptables rules there, and restored them from those files on each application server.
However, the task still wasn’t successful. Am I missing something? Is there a better way to make iptables rules persist?