To clear all rules in iptables I use this
#!/bin/bash
echo "clearing iptables ... "
sudo iptables -F
sudo iptables -X
sudo iptables -t nat -F
sudo iptables -t nat -X
sudo iptables -t mangle -F
sudo iptables -t mangle -X
sudo iptables -P INPUT ACCEPT
sudo iptables -P FORWARD ACCEPT
sudo iptables -P OUTPUT ACCEPT
This works so far as there are no entries in iptables any more, which is checked with
sudo iptables -L
or
sudo iptables -S
However, traffic that has been forwarded to a different target still is beeing routed to that target.
That seems like the cleared iptables still are active after clearing them!
Up to now my only way to get rid of those rules is to reboot the system which is not very elegant.
In Debian iptables doesn't seem to run as a service so start or stop of that service doesn't work.
How do I totally clear or reset iptables with the effect that previously defined rules are deactivated?
Best Answer
Maybe there is ufw running on? Try to stop.
Could you tell a littlem bit more about your system, network and which traffic is still routed?
1-2 examples are ok incl. the initial firewall rule.
EDIT:
Checked by some of my scripts..... Also flush the chains.