How to save iptables rules in Debian and Ubuntu?
from Infernal_pizza@lemmy.dbzer0.com to linux@lemmy.ml on 20 Sep 00:37
https://lemmy.dbzer0.com/post/53685093

I’m trying to set up some iptables rules in both Debian and Ubuntu, but I’m not sure how to make them persistent. As far as I understand the iptables package in the debian and Ubuntu repos is actually iptables-nft meaning I’m actually creating nftables rules, so I’m supposed to use iptables-nft-save to save them instead of using the normal method for iptables or nftables? But that command just seems to produce an output that doesn’t match the syntax for iptables or nftables and the man page is not very helpful.

I’m also confused why Ubuntu does seem to have the /etc/iptables/rules.v4 and v6 files but Debian doesn’t? Both seem to have /etc/nftables.conf as well but I’m not sure if that’s even used (the Ubuntu machine has a bunch of iptables rules already defined which don’t show up there but do show up in nft list ruleset)

#linux

threaded - newest

pastermil@sh.itjust.works on 20 Sep 01:01 next collapse

The iptables-persistent is your answer.

Infernal_pizza@lemmy.dbzer0.com on 20 Sep 09:04 collapse

Thanks that’s sorted it! I didn’t realise there was a separate package

Tenkard@lemmy.ml on 20 Sep 06:21 collapse

Ah worst you can use a shell script and a systemd service to apply them at boot