Lubos Rendek

The only solution is determination.

Remove All Iptables PREROUTING Nat Rules

| Comments

To Flush iptables PREROUTING chains cannot be achieved by -F iptables option. To remove PREROUTING nat rules from you system first display all PREROUTING chains using a following iptables command:

iptables -t nat --line-numbers -L

As you can see the above command will display all PREROUTING chains with relevant line numbers. Next, we can use these line numbers to remove all PREROUTING chains one by one. For example to remove PREROUTING chain with line number 6 we can do:

iptables -t nat -D PREROUTING 6

In case that you wish to remove all PREROUTING chains with a single command you can try the following command chaining example:

for i in $( iptables -t nat --line-numbers -L | grep ^[0-9] | awk '{ print $1 }' | tac ); do iptables -t nat -D PREROUTING $i; done