LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora
User Name
Password
Fedora This forum is for the discussion of the Fedora Project.

Notices


Reply
  Search this Thread
Old 02-10-2022, 05:59 AM   #1
linuxgurusa
Member
 
Registered: Mar 2008
Location: Namibia, Swakopmund
Distribution: Redhat, Fedora, Centos, ClearOS, Mandrake
Posts: 151

Rep: Reputation: 29
Auto start iptables script file fedora 35


Hi guys, please assist, step my step even if needed.

I recently migrated to Fedora 35 , using Centos all these years, but Centos is now EOL as of end 2021.

I always made a script file under /etc/rc.d/init.d/firewall which contains a proper iptables firewall script file I have been using for all these years.

I made some minor changes, and even works 100% on a Fedora 35 server.

Problem is that when the server reboots, obviously no rules are loaded, because Fedora 35 don't boot scripts anymore

I even tried running the script, all works 100%, then do a iptables-save > /etc/sysconfig/iptables. But when I restart, no internet access, even confirming the saved iptables rules are still there ?? but once I run my script file again under /etc/rc.d/init.d/firewall, everything works again 100%

Please help ...
 
Old 02-10-2022, 07:02 AM   #2
jmgibson1981
Senior Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 1,141

Rep: Reputation: 392Reputation: 392Reputation: 392Reputation: 392
Rebuild your script into a case statement. Then call it with a systemd service as such.

Code:
[Unit]
Description = Creates router iptables configuration
After = network.target
Requires = network.target

[Service]
User = root
Group = root
Type = oneshot
ExecStart = /usr/local/bin/homerouter.sh load %i
ExecStop = /usr/local/bin/homerouter.sh stop %i
RemainAfterExit = yes

[Install]
WantedBy = multi-user.target
 
Old 02-10-2022, 07:49 AM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,722

Rep: Reputation: 5916Reputation: 5916Reputation: 5916Reputation: 5916Reputation: 5916Reputation: 5916Reputation: 5916Reputation: 5916Reputation: 5916Reputation: 5916Reputation: 5916
There should be an iptables service that needs to be enabled.

sudo systemctl enable iptables

That should run the iptables-restore script at boot up

https://docs.fedoraproject.org/en-US...ptables-rules/

Last edited by michaelk; 02-10-2022 at 08:24 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Ubuntu 14.04 x64 - xfce with vnc - auto login, auto start wine app kingkong89 Ubuntu 0 09-30-2015 08:45 PM
iptables v1.2.9: Unknown arg `/sbin/iptables' Try `iptables -h' or 'iptables --help' Niceman2005 Linux - Security 4 12-29-2005 08:20 PM
How do I auto start modules that aren't auto loaded on boot? darkbluedrew Debian 2 09-18-2005 09:10 AM
eth0 Auto Connect, How to auto start on logon cornish Linux - Networking 2 05-09-2005 12:02 PM
auto-completion - how does it work & can my script args auto-complete? BrianK Programming 1 06-11-2004 04:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora

All times are GMT -5. The time now is 07:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration