Skip to content

Instantly share code, notes, and snippets.

@jstrosch
Created July 27, 2012 21:31
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save jstrosch/3190568 to your computer and use it in GitHub Desktop.
Save jstrosch/3190568 to your computer and use it in GitHub Desktop.
iptables - delete all rules/chains
#view current chains
$ iptables -L
#remove/flush all rules & delete chains
$ iptables -F
$ iptables -X
$ iptables -t nat -F
$ iptables -t nat -X
$ iptables -t mangle -F
$ iptables -t mangle -X
$ iptables -P INPUT ACCEPT
$ iptables -P OUTPUT ACCEPT
$ iptables -P FORWARD ACCEPT
-F : Deleting (flushing) all the rules.
-X : Delete chain.
-t table_name : Select table (called nat or mangle) and delete/flush rules.
-P : Set the default policy (such as DROP, REJECT, or ACCEPT).
@dynek
Copy link

dynek commented Oct 8, 2019

Don't forget raw

@develforever
Copy link

develforever commented Nov 7, 2020

iptables -t raw -F
iptables -t raw -X
and maybe this is good to place at first because

Accept all traffic first to avoid ssh lockdown via iptables firewall rules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment