Score:0

Fedora | how to restore iptables from specific file on boot

vn flag

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

Zareh Kasparian avatar
us flag
do you have rc.local file under /etc/rc.local path? it depends on your Fedora version. If yes, then place your script in this file. any script in this file will be executed during boot.
Or Yaacov avatar
vn flag
that solved my problem, please write it as an answer and mention tha rc-local.service needs to be active :)
Score:1
us flag

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.

Score:0
mu flag

I believe that the correct file to make it persistent is:

/etc/sysconfig/iptables

This according to the documentation

Or Yaacov avatar
vn flag
thank you for your answer, but didn't solve what i was ask for, since it's require to install iptables-services / iptables-persistent
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.