1

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?

3 Answers 3

1

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

0

Put the changes in /etc/sysconfig/iptables.

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

2
  • I've already made this, but not works for my server
    – kakals1
    Oct 14, 2010 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/iptables.save, 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, 2010 at 12:08
0

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.

You must log in to answer this question.