Reset iptables to default (accept all) without restart

If you haven’t done anything to preserve iptables settings on reboot, a restart could clear out all settings, but if you do not want to restart, you can use this:

You will need to run all this as root, or with sudo.

Note that the default for debian or ubuntu is to allow all, this might be a security risk if you were depending on iptables rules to add security by blocking access to certain ports or other sorts of rules to manage incoming/outgoing traffic, use this with caution.

iptables -t filter -P INPUT ACCEPT
iptables -t filter -P FORWARD ACCEPT
iptables -t filter -P OUTPUT ACCEPT
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P INPUT ACCEPT
iptables -t nat -P OUTPUT ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
iptables -t mangle -P PREROUTING ACCEPT
iptables -t mangle -P INPUT ACCEPT
iptables -t mangle -P FORWARD ACCEPT
iptables -t mangle -P OUTPUT ACCEPT
iptables -t mangle -P POSTROUTING ACCEPT
iptables -t raw PREROUTING ACCEPT
iptables -t raw OUTPUT ACCEPT
iptables -t security -P INPUT ACCEPT
iptables -t security -P FORWARD ACCEPT
iptables -t security -P OUTPUT ACCEPT
 
iptables -t filter -F
iptables -t filter -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -t raw -F
iptables -t raw -X
iptables -t security -F
iptables -t security -X

Leave a Reply

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

(Your message will only be visible after moderation)