Wednesday, April 12, 2023

Flushing and Clearing iptables Rules

Sometimes we need to clear out iptables, and start from scratch in setting up firewall rules. In order to do that, below are the commands to follow

sudo iptables -t nat -F
sudo iptables -t mangle -F
sudo iptables -F
sudo iptables -X

The first command flush out rules in nat table. The second one will flush rules in mangle table. The third command will flush all rules in all chains. The last one will delete all non default chains in iptables.

In order to verify, we can use below command:
sudo iptables -L -n

The above command will print out all rules in all chains, and all port and ip address will be printed in numeric format. 

Cleared out iptables will look like below: 









No comments: