Table of Contents

, ,

Save iptables rules and clear firewall

Useful for debugging.

First, save the current firewall config:

iptables-save > /root/firewall.rules
ip6tables-save > /root/firewall6.rules

Then, flush and open all the firewall rules using the following 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 OUTPUT ACCEPT
iptables -P FORWARD ACCEPT

For IPv6 rules, substitute ip6tables instead of iptables.

After testing, you can re-enable your firewall rules by running the following:

iptables-restore < /root/firewall.rules
ip6tables-restore < /root/firewall6.rules

Tested on

See also

References