1

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)?

Gnanam
  • 1,529
  • 13
  • 27
  • 32

2 Answers2

11
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
Prix
  • 5,329
1

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

vigour
  • 26