I have a script which loads iptables at
#!/bin/sh iptables-restore < /etc/iptables.rules ip6tables-restore < /etc/ip6tables.rules exit 0
I also have a script which save iptables at
#!/bin/sh # By saving the current iptables rules to the file at the specific path, # then they will be loaded on every startup. echo "Saving current iptables rules..." iptables-save -c > /etc/iptables.rules if [ -f /etc/iptables.downrules ]; then iptables-restore < /etc/iptables.downrules fi ip6tables-save -c > /etc/ip6tables.rules if [ -f /etc/ip6tables.downrules ]; then ip6tables-restore < /etc/ip6tables.downrules fi exit 0
I have a file at path
/etc/iptables.rules which contains all the rules.
When I manually execute
iptables-restore < /etc/iptables.rules then I can see all iptables rules.
But after powering on the PC, then all iptables rules are missing (all is empty).
My conclusion is that the scripts in folders
/etc/network/if-pre-up.d don't execute. Why?
/etc/iptables.rules exists because I manually executed
iptables-save -c > /etc/iptables.rules.)
I'm using the exact same scripts that I used for Ubuntu 18 - they worked well.
The above is originally taken from:
I also tried copying exactly as they write in the link above, but still iptables failed to load.