How to clear iptables rules and save them on Ubuntu.


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:

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

Additionally if you would like to save these (so new rules applies after rebot as well) try this

First install this fella:

sudo apt-get install iptables-persistent


and run this after changes are done:

sudo netfilter-persistent save

Leave a Reply

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

You are commenting using your 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