-1

I have installed iptables-persistent on my Ubuntu 18.04 server and search for a solution that I don't need to save the iptables configuration (iptables-save > /etc/iptables/rules.v4) every time before a reboot or shutdown.

So I created the following script (/etc/init.d/iptables-save) with the command and made it executable.

#!/bin/sh
iptables-save > /etc/iptables/rules.v4

After that I created a link in /etc/rc6.d:

ln -s /etc/init.d/iptables-save /etc/rc6.d/K01iptables-save

Now it should be executed before a shutdown, but it doesn't work.

Why doesn't that work? Is there another way to execute this one command before a shutdown/reboot?

  • You are not using ufw? – Michael Hampton Feb 1 at 20:20
  • This is 18.04? Isn't that using systemd? Did you manually make those symlinks? I wonder if you have to do a systemctl daemon-reload for the systemd-sysv-generator to see that you changed something. Anyway try another reboot after that change. – Zoredache Feb 1 at 21:03
2

The package netfilter-persistent or iptables-persistent should contain all you're looking for.

  • I have netfilter-persistent and iptables-persistent both installed on my system, but what do I need to configure? – Migster Feb 1 at 21:04
  • Just enable the service with systemctl enable netfilter-persistent. You can test with systemctl start|stop netfilter-persistent. There is also a configuration file in /etc/default/netfilter-persistent. – hargut Feb 2 at 9:53
  • I enabled netfilter persistent and started the service but it still doesn't work. In the directory /usr/share/netfilter-persistent/plugins.d/ there are the two files 15-ip4tables 25-ip6tables – Migster Feb 2 at 10:50

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.