Been looking where does netfilter-persistent store its rules but could not find any documentation about it on help.ubuntu.com.
Does anybody know where does netfilter-persistent in Ubuntu save its rules so it survives a reboot?
Found it only works if you install 'iptables-persistent' package as well.
sudo apt-get install iptables-persistent netfilter-persistent
It will be saved in /etc/iptables/rules.v[4-6]
If you only install netfilter-persistent, it wont save any configuration
Ignivs' answer is perfect. However, I want to complement it a little.
In man netfilter-persistent
, it says "All plugins are stored in /usr/share/netfilter-persistent/plugins.d". Part of /usr/share/netfilter-persistent/plugins.d/15-ip4tables
reads
save_rules()
{
if [ ! "${IPTABLES_SKIP_SAVE}x" = "yesx" ]; then
touch /etc/iptables/rules.v4
chmod 0640 /etc/iptables/rules.v4
iptables-save > /etc/iptables/rules.v4
fi
}
Then we know that the rules are actually saved by iptables-save
and stored in /etc/iptables/rules.v4
.
sudo apt install iptables-persistent
is enough. It will installnetfilter-persistent
as dependency automatically. – ruuter Mar 18 '20 at 12:23