How to clear iptables rules and save them on Ubuntu.

iptables

Just recently I’ve been testing something on an appliance with Ubuntu, and wanted to clear out all of the iptables entries, this is what worked for me:

http://wiki.loovsys.eu/index.php/Clear_all_iptable_rules_and_allow_everything

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

Additionally if you would like to save these (so new rules applies after rebot as well) try this https://www.digitalocean.com/community/tutorials/iptables-essentials-common-firewall-rules-and-commands:

First install this fella:

sudo apt-get install iptables-persistent

 

and run this after changes are done:

sudo netfilter-persistent save
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s