I need some help, or advice.
I have a latest server I am trying to get into production and I cannot get it to load its rules on a reboot.
"Debian GNU/Linux 10 (buster)" it is up to date in its packages
I have installed iptables-persistent, I have ran dpkg-reconfigure iptables-persistent
, and it does save the rules in /etc/iptables
I have the following in the folder
rules.v4 rules.v6
On a reboot it will not load my rules. IF I do this below, it works just fine! IT will just not do this for me on reboot.
iptables-restore < /etc/iptables/rules.v4
I have tried following many leads online, starting from these.
Why do iptables rules disappear when restarting my Debian system?
Why isn't the Iptables persistent service saving my changes?
I don't know what I am doing wrong. I do have fail2ban installed and working. I can't see this conflicting, but on boot they both would be working with iptables...
Are there ways to view the iptables logs? Does it log to journalctl? I cannot find any msges that can give me an idea why it is not working.
These rules gotta load on boot. Someone did mention to load this in /etc/rc.local
, which I am unfamiliar with, that file is not there on Debian, and some have explained to just stick with iptables-persistent, which I would tend to agree with.
Why do iptables rules disappear when restarting my Debian system?
Any help is appreciated, or logs to iptables if any.
This is my boot logs when I try a reboot journalctl -f -unetfilter-persistent
Jan 02 15:09:06 domain.ca netfilter-persistent[720]: run-parts: executing /usr/share/netfilter-persistent/plugins.d/25-ip6tables start
Jan 02 15:09:06 domain.ca systemd[1]: Started netfilter persistent configuration.
Jan 02 15:09:50 domain.ca systemd[1]: Stopping netfilter persistent configuration...
Jan 02 15:09:50 domain.ca netfilter-persistent[1434]: Automatic flush disabled; use '/usr/sbin/netfilter-persistent flush'
Jan 02 15:09:50 domain.ca systemd[1]: netfilter-persistent.service: Succeeded.
Jan 02 15:09:50 domain.ca systemd[1]: Stopped netfilter persistent configuration.
Jan 02 15:09:50 domain.ca systemd[1]: Starting netfilter persistent configuration...
Jan 02 15:09:50 domain.ca netfilter-persistent[1436]: run-parts: executing /usr/share/netfilter-persistent/plugins.d/15-ip4tables start
Jan 02 15:09:50 domain.ca netfilter-persistent[1436]: run-parts: executing /usr/share/netfilter-persistent/plugins.d/25-ip6tables start
Jan 02 15:09:50 domain.ca systemd[1]: Started netfilter persistent configuration.
nftables
asiptables
is deprecated, less and less maintained and absent from recent Linux distributions by default. Also, nftables has a built-in systemdnftables.service
for creating your ruleset (from/etc/nftables.conf
) automatically during boot. – Totor Dec 27 '22 at 18:23iptables
package contains two versions ofiptables
command:iptables-legacy
actually uses the iptables kernel components, but the defaultiptables-nft
actually uses nftables although the command syntax is identical to iptables. What you get with justiptables
is switchable withsudo update-alternatives --config iptables
- but at least Debian 11 and I think 10 too will default to the nftables version. – telcoM Dec 29 '22 at 21:21nft
though (usingnft list ruleset
to dump the nftables config once your firewall is configured as you like). Then, use the default mechanism (systemdnftables.service
) to start it at boot. – Totor Jan 02 '23 at 03:04