Why is iptables-restore failing to load my rules?

Why is iptables-restore failing to load my rules?

I’m setting up a mail server, but when writing to the iptables, I get an error: iptables-restore: line 2 failed. iptables-restore: line 2 failed. I don’t know what the problem is.

Why does iptables-ip6table-restore fail in Debian Buster?

To confirm this is the case, check for (nf_tables): This option has no effect in iptables and iptables-restore. If a rule using the -4 option is inserted with (and only with) ip6tables-restore, it will be silently ignored. Any other uses will throw an error.

What to do if iptables is not loading in Ubuntu?

Add a line with just *filter at the top of the file. Add a line with just COMMIT at the bottom. There’s a few other snippets it should have too but that should make it work.

How to dump iptables rules in Kernel 4.19?

You can dump them with iptables-nft-save + ip6tables-nft-save and restore them with iptables-save + ip6tables-save. This will result in rules running twice: once with kernel’s iptables backend, once with kernel’s nftables backend, and NAT might not always work correctly with this on kernel 4.19 (usually the first loaded module wins: here nft_nat).

Is there a blank line after iptables restore?

There must be a blank line after COMMIT or iptables-restore will fail with a “no command specified” error at the line COMMIT is on. Due to the way iptables-restore works, almost all errors will be reported as being at the COMMIT point.

Why does iptables report errors at the commit point?

Due to the way iptables-restore works, almost all errors will be reported as being at the COMMIT point. On the odd occasion I have these errors, I go putting COMMITs after each significant line (or, if I’m feeling suspicious, after just the lines I think might be the problem) and seeing which one barfs.

How to add rules to iptables in Vim?

You can run iptables -A INPUT -p tcp -m tcp –dport 3000 -j ACCEPT then iptables-save to append the rule to the appropriate chain. If you must edit the /etc/sysconfig/iptables file then do so with vim or vi and insert the rules at line 18.