1

I installed iptables and iptables-persistent in order to save the rules and apply them after reboot, however whenever I try to restore or save I get this errors:

  1. with sudo netfilter-persistent save : usr/share/netfilter-persistent/plugins.d/15-ip4tables: 45: /usr/share/netfilter-persistent/plugins.d/15-ip4tables: /sbin/modprobe: not found
  2. with sudo netfilter-persistent reload after reboot: the rules were not saved so it does not block with my rule: sudo iptables -I INPUT -p icmp --icmp-type 8 -i eno1 -j DROP
  3. I've tried to save with iptables-save > /etc/iptables/rules.v4 && ip6tables-save > /etc/iptables/rules.v6 but it doesn't seem to add the rule, and after reboot
  4. sudo iptables-restore < /etc/iptables/rules.v4 sends: Bad argument '[unsupported' Error occurred at line: 30

my Ubuntu version is 18, please help save rules after reboot

EDIT: my error on 2: /usr/share/netfilter-persistent/plugins.d/25-ip6tables: 45: /usr/share/netfilter-persistent/plugins.d/25-ip6tables: /sbin/modprobe: not found

Yuki1112
  • 111
  • 4

2 Answers2

1

Regarding number 4: The error message you have received is quite specific - there appears to be an error on line 30 of /etc/iptables/rules.v4. If there is an error in this file, then the rules will not load at boot.

Make sure you have iptables-persistent and netfilter-persistent to ensure that this works properly. I wrote a good write up of this here: Iptables reload/restart on Ubuntu

ThankYee
  • 1,708
  • I didn't install both, I'll try that now on my docker, I also want to make sure of something- I tried to subprocess.call to sudo netfilter-persistent reload right as the system boots (added that to a script that runs as it boots), will that affect? – Yuki1112 Jul 26 '22 at 08:34
0

So I found the problem regrading 1&2: You need reinstall the module of modprode, read more here: https://bugs.launchpad.net/ubuntu/+source/iptables-persistent/+bug/1820144

Basically just install apt-get --reinstall install module-init-tools before apt install -y iptables-persistent netfilter-persistent and it will work

Yuki1112
  • 111
  • 4