Fedora – How to Restore Iptables from Specific File on Boot

centosfedoraiptablesredhat

I need to make ip-tables persistent on my machines.
I was able to do it on Debian based systems by creating the following file which runs when my network is up:

/etc/network/if-up.d/run-iptables

#!/bin/sh
iptables-restore /etc/iptables/rules.v4

I tried to do the same on Fedora based systems (CentOS, RHEL, Fedore…) using the following file:
/etc/sysconfig/network-scripts/ifup
but unfourtantly it doesn't work.

any ideas on how to perform this without using any additional service?

Thank you

Best Answer

You may use rc.local file under /etc/rc.local path.

Just make sure that rc.local file is executable : Run the following command to check whether file /etc/rc.local is executable:

ls -l /etc/rc.local
  -rwxr-xr-x 1 root root 419 2022-03-07 11:26 /etc/rc.local

Traditionally, the shell script /etc/rc.local used by developers and Linux sysadmin to call other scripts or commands after all services are loaded. Typically /etc/rc.local get called at the end when Linux init switched to a multiuser runlevel.

Related Topic