Delete more than 1 line in iptables.
Posted: 2013/09/22 17:42:55
Good day all,
I was wondering if anyone is out there who's managed to delete more than 1 line in iptables. The man page says and I quote
-D, --delete chain rulenum
Delete one or more rules from the selected chain. There are two versions of this command: the rule can be specified as a number in the chain (starting at 1 for the first rule) or a rule to match.
So I've been trying a few iterations trying to delete say lines 1 2 3 4 just as an example.
iptables -vnL INPUT --line-numbers (works and it shows me the line numbers I want to delete)
then I try:
iptables -D INPUT 1-4
or
iptables -D INPUT 1,2,3,4
I know I can do iptables -D INPUT 1 and this works but my goal is not have to do that 4 times, :-)
command doesn't work, the man page seems limited with this command and my searches have turned up nothing as far as deleting multiple lines in a single command. Short of writing a bash script does anyone have any knowledge on leveraging this type of command and with the syntax I've exampled here? perhaps just a small limitation of the iptables :-D ?
Thanks .
O
I was wondering if anyone is out there who's managed to delete more than 1 line in iptables. The man page says and I quote
-D, --delete chain rulenum
Delete one or more rules from the selected chain. There are two versions of this command: the rule can be specified as a number in the chain (starting at 1 for the first rule) or a rule to match.
So I've been trying a few iterations trying to delete say lines 1 2 3 4 just as an example.
iptables -vnL INPUT --line-numbers (works and it shows me the line numbers I want to delete)
then I try:
iptables -D INPUT 1-4
or
iptables -D INPUT 1,2,3,4
I know I can do iptables -D INPUT 1 and this works but my goal is not have to do that 4 times, :-)
command doesn't work, the man page seems limited with this command and my searches have turned up nothing as far as deleting multiple lines in a single command. Short of writing a bash script does anyone have any knowledge on leveraging this type of command and with the syntax I've exampled here? perhaps just a small limitation of the iptables :-D ?
Thanks .
O