Occasionally I find it necessary to quickly clear out all the IPTables rules without accidentally losing access to the machine.  I've found the below commands to be the quickest way to accomplish that goal (substitute ip6tables if you live in an IPv6 world)

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

You can confirm afterward by running iptables -nvL, which should produce output similar to:

Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination