sudo apt install iptables-persistent netfilter-persistent
systemctl enable netfilter-persistent netfilter-persistent save netfilter-persistent start iptables-save > /etc/iptables/rules.v4 ip6tables-save > /etc/iptables/rules.v6 iptables-restore < /etc/iptables/rules.v4 ip6tables-restore < /etc/iptables/rules.v6 systemctl stop netfilter-persistent systemctl start netfilter-persistent systemctl restart netfilter-persistent
Remove persistent iptables rules
To remove persistent iptables rules simply open a relevant /etc/iptables/rules.v*
file and delete lines containing all unwanted rules.
References
https://askubuntu.com/questions/1052919/iptables-reload-restart-on-ubuntu-18-04
https://linuxconfig.org/how-to-make-iptables-rules-persistent-after-reboot-on-linux