6

I have saved my iptables rules using the iptables-save > command and i am trying to restore these rules when the machine boots up. I have added the command iptables-restore < "path to rules file" in the rc.local but it doesn't fire up the rules.

I tried directly running the command in the terminal and it worked, so i know there is nothing wrong with the command. I have made the rc.local file executable as well with the command sudo chmod +x /etc/rc.local.

What might be the problem ?

Edit - am using fedora 22

MadHatter
  • 78,442
  • 20
  • 178
  • 229
Troller
  • 171
  • 1
  • 4

2 Answers2

7

I'm afraid time has moved on, and F22 is one of those cherishable distros using the adorable new systemd to start things up. One of the many happy enjoyable side effects is that rc.local is no longer run (or to be more precise, I haven't been able to make it run reliably) so that won't be helping.

Put your firewall rules into /etc/sysconfig/iptables in the normal way, using iptables-save > /etc/sysconfig/iptables, clear your rules, then do systemctl start iptables.service to apply them. If iptables -L -n -v confirms they've taken, do systemctl enable iptables.service to start them at boot time.

MadHatter
  • 78,442
  • 20
  • 178
  • 229
  • Executing `/etc/rc.local` is simply disabled by default because of some unknown `systemd` ideology. Just run `systemctl enable --now rc-local` to permanently enable it and immediately execute the commands in the file. – Mikko Rantalainen Aug 24 '22 at 09:52
0

check if iptables is started on boot, chkconfig --list iptables

default
  • 1
  • 2