Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Im on CentOS 5.5 64 bit.I've added some rules in iptables as usual.

all changes has been saved with sudo service iptables save and all rules added by using command line

but after reboot, all the rules back to previous state.
this not happen on my previous server running centos 32 bit.

How to make the changes persistent?

share|improve this question

You're probably running some other firewall service instead of the stock iptables service, so your rules are not being loaded.

share|improve this answer

Put the changes in /etc/sysconfig/iptables.

The /etc/init.d/iptables script applies this file using iptables-restore.

share|improve this answer
I've already made this, but not works for my server – kakals1 Oct 14 '10 at 14:00
Have a look at /etc/sysconfig/iptables-config. It contains settings that affect the backup/restore of rules upon firewall restart. By default save on stop/restart should be set to no. What is the "previous state" of your firewall ? Empty ? BTW "service iptables save" makes use of /etc/sysconfig/iptables and /etc/sysconfig/, which are empty if your firewall is deactivated. Use system-config-security-tui to enable it and have a look at the generated files. – Rosco Oct 15 '10 at 12:08

Try this:

cd /etc/sysconfig
copy iptables my-iptables

Then edit my-iptables with your rules. Then, as root:

iptables-restore < my-ip-tables

When you need to edit your iptables in future, edit my-iptables and use iptables-restore to do the update.

See also iptables-howto which mentions iptables-save as an alternative method for updating, which may be closer to what you tried to do already. However, I think having a separate file for making changes is better than editing iptables file directly.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.