netfilter-persistent restart after reboot

I need to run:

sudo service netfilter-persistent restart

after I reboot my server, in order for port 25 to be opened. I would like to automate this. How should I configure this?

I already tried:

sudo systemctl enable netfilter-persistent

but that didn't help. I'm running Debian 9.


Solution 1:

persistent` may not be having the desired effect you intend without carrying out a save.

Normally iptables-save will suffice but if that's not working you can write the rules directly via the following. iptables-save >/etc/iptables/rules.v4

This should provide you with the desired outcome of having port 25 open on boot

With regards to your initial question.

systemctl enable netfilter-persistent would all that's required to enable the service.

You have not specified the status of the service if it's running or not post boot.

If you can please check systemctl status netfilter-persistent post boot to confirm it is actually running vs failed etc.

Passing disable , then enable can resolve some issues with bad hooks.