Flushing iptables

You can flush and reset iptables to default running these commands:

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 FORWARD ACCEPT
iptables -P OUTPUT ACCEPT

The -F command flushes all the chains and -X deletes empty (non-default) chains.
You can also create a script:

#!/bin/sh
echo "Flushing..."
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 FORWARD ACCEPT
iptables -P OUTPUT ACCEPT

By default, the script will have 644 permissions so you have to make it executable:

chmod +x flush_iptables.sh

Leave a Reply

Your email address will not be published. Required fields are marked *