Wednesday, November 21, 2012

Deleting iptables Rules by Line Number

Looking for a simple way of deleting a specific iptable rule? Well, here it is...

First display all rules by line numbers (this will show a list of the rules by line):
iptables -L INPUT -n --line-numbers
# or/and
iptables -L OUTPUT -n --line-numbers

Then use the line number to delete the rule:
tables -D INPUT 1  # where "1" is the line number or the rule

No comments: