iptables - remove a rule (-D --delete)
by
Jeremy Canfield |
Updated: November 15 2021
| iptables articles
Let's say iptables --list-rules command returns the following output. The nice this about this output is that is provides you with the exact format that can be used to delete a rule.
~]# iptables --list-rules
-A INPUT -d 172.17.0.2/32 ! -i eth0 -p tcp -m tcp --dport 80 -j ACCEPT
-P FORWARD DROP
-P OUTPUT ACCEP
Here is how you would delete a rule. You simply take the above output and replace -A (append) with -D or --delete.
iptables -D INPUT -d 172.17.0.2/32 ! -i eth0 -p tcp -m tcp --dport 80 -j ACCEPT
Did you find this article helpful?
If so, consider buying me a coffee over at