How to flush and reset all iptables rules from the server?

If you need to completely reset the firewall rules to a clean, open state, follow the steps below.
Warning: This will remove all existing firewall rules and allow all traffic.


1. Set Default Policies to ACCEPT

This ensures no traffic is blocked after flushing the rules.

iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT

2. Flush and Delete All Chains

Removes all existing rules and user-defined chains.

iptables -t nat -F
iptables -t mangle -F
iptables -F
iptables -X

3. Verify Rules

List current rules to confirm they’ve been cleared.

iptables -L -n -v

4. Save the Firewall Changes

Persist the current (empty) configuration.

service iptables save

5. Check NAT Table Output Rules

To view NAT OUTPUT chain details with line numbers:

iptables -t nat -L OUTPUT -n -v --line-numbers

6. Clear IPv6 Firewall Rules (ip6tables)

If IPv6 is enabled, reset those rules as well:

ip6tables -P INPUT ACCEPT
ip6tables -P FORWARD ACCEPT
ip6tables -P OUTPUT ACCEPT
ip6tables -t nat -F
ip6tables -t mangle -F
ip6tables -F
ip6tables -X

7. Verify IPv4 and IPv6 Rules

To confirm everything is cleared:

iptables -L -n -v
ip6tables -L -n -v
  • iptables, security, protection, bypass, cpanel, centos 6, directadmin
  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

Domain names are not showing in WHM

We were unable to see any domains listed under WHM -> List Accounts. However, we can see the...

How to Start/Stop or Restart Apache server

Apache is the HTTP server that is freely available over the internet. It is a kind of software or...

How to install Attracta SEO Tools plugin

RequirementscPanel/WHM needs to be installed on your server. Step 1: SSH into your server and go...

How to Install CpCleaner in cPanel through SSH?

Installation Run the following shell commands as root via SSH: wget -O cpc-1.0.3.tar...

How to Secure a cPanel/WHM Web Server

Here are a few basic steps that you should keep in mind for keeping a server secure. 1) Strong...