Flushing all the tables in the firewall

How do I flush all the iptables (IPv4) tables in the firewall using command line ssh session?

## Flush Any Existing Rules or Chains...

# Reset Default Policies
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
iptables -t nat -P OUTPUT ACCEPT
iptables -t mangle -P PREROUTING ACCEPT
iptables -t mangle -P OUTPUT ACCEPT

# Flush all rules
iptables -F ; iptables -t nat -F ; iptables -t mangle -F

# Erase all non-default chains
iptables -X ; iptables -t nat -X ; iptables -t mangle -X

## Done.

Check my blog post


Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki