LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-11-2011, 07:29 AM   #1
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 632

Rep: Reputation: 33
IPtables rules flushed with reboot ?


Hello,

I notice that my firewall rules are flushed with a reboot. Is that some setting or so ?
 
Old 10-11-2011, 08:32 AM   #2
fukawi1
Member
 
Registered: Apr 2009
Location: Melbourne
Distribution: Fedora & CentOS
Posts: 854

Rep: Reputation: 190Reputation: 190
Fedora (15 at least) will load saved iptables rules from /etc/sysconfig/iptables , so if you are loading your rules manually via a script, you need to save the rules using
Code:
iptables-save > /etc/sysconfig/iptables
(note this will overwrite any existing saved rules, so it may be worth taking a backup)and it should load them whenever the init script is called (ie: boot time, or via service)
 
Old 10-11-2011, 09:48 AM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
It is common practice to use shell scripts to establish a functional set of iptables rules. The rules are edited in the shell script, and then the script is run to load the rules set. The script can be hooked into the system startup scripting in order to automatically load at boot-time. Usually, there is provision in the script to flush all of the rules, and then successively re-build the set of rules as the script runs. This allows you edit the script to add new functionality, and then run the script to install the new features.

--- rod.
 
Old 10-11-2011, 11:49 AM   #4
rng
Senior Member
 
Registered: Aug 2011
Posts: 1,014

Rep: Reputation: 25
I think ufw (uncomplicated firewall- default in ubuntu) and firestarter firewall frontends, if installed, affect iptables at startup. They also change iptables rules when network is switched off or on. You may want to uninstall these if you have your own firewall iptables rules.

In ubuntu, following line inserted in file /etc/rc.local will load iptables rules at startup:

iptables-restore < myrules.saved

(no sudo needed in this file). File 'myrules.saved' is obtained by following command:

sudo iptables-save > myrules.saved

Last edited by rng; 10-11-2011 at 11:57 AM.
 
Old 10-11-2011, 02:16 PM   #5
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 632

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by fukawi1 View Post
Fedora (15 at least) will load saved iptables rules from /etc/sysconfig/iptables , so if you are loading your rules manually via a script, you need to save the rules using
Code:
iptables-save > /etc/sysconfig/iptables
(note this will overwrite any existing saved rules, so it may be worth taking a backup)and it should load them whenever the init script is called (ie: boot time, or via service)
I use CSF (http://configserver.com/cp/csf.html). I don't really know if this "script" saves the rules...

I use CentOS 5.6

On another server I do not have this problem... And I can't find a difference...

Last edited by jonaskellens; 10-11-2011 at 02:17 PM.
 
Old 10-13-2011, 03:23 AM   #6
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 632

Original Poster
Rep: Reputation: 33
I have solved my problem by removing the file /etc/sysconfig/iptables

This file indeed had some basic firewall rules which were read on reboot.

Now, when I reboot, my firewall rules which I set through CSF are kept.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Restore iptables Rules that have been saved with iptables-save tiuz Linux - Security 4 08-14-2010 05:50 PM
iptables flushed unexpectedly jwhitehead Linux - Networking 1 07-06-2008 12:37 AM
iptables 1.27a still loading rules after installing iptables 1.3.0 yawe_frek Linux - Software 1 06-07-2007 09:50 PM
iptables firewall rules not surviving reboot BurceB7 Linux - Newbie 3 03-11-2004 11:45 AM
IPTABLES rules not saving on reboot blueplazma Linux - Security 1 01-02-2003 09:36 PM


All times are GMT -5. The time now is 02:28 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration