Plainnotes

Firewall rules gone after a reboot

2024-07-05 · 2 min readNetwork

A pile of iptables -A commands vanished on reboot — rules exist only in kernel memory unless saved.

Persistence depends on the distribution. Debian and Ubuntu use iptables-persistent and netfilter-persistent save, writing /etc/iptables/rules.v4. RHEL-family systems use iptables-services with service iptables save. With ufw, rules already live in /etc/ufw/ and load on enable. With nftables, put them in /etc/nftables.conf and enable the unit.

The easiest answer is not to type rules by hand: ufw and firewalld persist by design.

Verify by comparing iptables-save before and after a reboot.