Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

My server is Red Hat Enterprise Linux Server release 5.

What is the correct/proper command to clear all existing iptables rules defined in /etc/sysconfig/iptables (so that I can start defining/adding my new rules)?

share|improve this question
up vote 1 down vote accepted

1) Method:

Install system-config-firewall and setuptool RPMs. Start "setup", go to "Firewall configuration" and disable the firewall.

Add your own rules.

Start setup and enable the firewall.

2) Method:

Flush iptables using: /etc/init.d/iptables stop

Add your own rules and save the change with:

/etc/init.d/iptables save

Start the configuration:

/etc/init.d/iptables start

share|improve this answer
Using method 2, will it allow to add and save rules once iptables is stopped using /etc/init.d/iptables stop? – Gnanam Aug 4 '10 at 12:24
@Gnanam yes it does, iptables is a element part of the system you don't actually STOP it from working you simple flush all the rules when you stop it. you can verify it yourself by stopping it and then trying to run the command iptables -L – Prix Aug 4 '10 at 18:16
Your method 2 is very simple and straight forward. This is what exactly I was looking for. Instead of me manually cleaning-up all existing rules, this method 2 approach is automatically taking care of this. Even I've followed this same steps in my server and the solution is working. – Gnanam Aug 5 '10 at 7:02
the above method is basicly all the commands you need to use manually being done via the iptables init script; – Prix Aug 5 '10 at 8:08
iptables -F // flush all chains
iptables -t nat -F
iptables -t mangle -F
iptables -X // delete all chains

Update the file with the current rules (not needed after the above steps but for further references)

iptables-save -c > /etc/iptables-save
share|improve this answer
I've a question here. The first command alone iptables -F is not sufficient to delete all the rules? Do I still need to run all the next 3 commands as well? – Gnanam Aug 4 '10 at 7:14
@Gnanam yes, you can confirm that by running iptables -L table where table would be nat for example. – Prix Aug 4 '10 at 7:20
Your answer 'Yes' is to which one of my above 2 questions? 1) Execute just first command alone 2) Execute all the 4 commands. – Gnanam Aug 4 '10 at 8:36
the answer is for you try it, experience. Those are simple commands and you can always run iptables-restore to bring back what you had previously. – Prix Aug 4 '10 at 8:47

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.