Hi,
I got your first rule for a test in a machine which does not run firewall, so I could put any rule for a run:
Code:
Opiii:~# iptables --list
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Opiii:~# iptables -A INPUT -m iprange --src-range 21.21.0.0-21.21.0.254 -j DROP
Opiii:~# iptables --list
Chain INPUT (policy ACCEPT)
target prot opt source destination
DROP all -- anywhere anywhere source IP range 21.21.0.0-21.21.0.254
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Opiii:~# iptables -D INPUT -m iprange --src-range 21.21.0.0-21.21.0.253 -j DROP
iptables: Bad rule (does a matching rule exist in that chain?)
Opiii:~# iptables -D INPUT -m iprange --src-range 21.21.0.0-21.21.0.254 -j DROP
Opiii:~# iptables --list
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
I did the following operations:
- list the rules, showing it's clean;
- append an iprange rule;
- list the rules to see if it was accepted;
- try to delete an non existing rule;
- try to delete an existing rule;
- list the rules again;
So, as you can see, the "bad rule message" is for rules you don't have in your firewall. When a rule is accepted, it is done quietly.
As you try to delete two rules at once, one for input and another for output, you receive 2 "bad rule" messages for each "Blocked:' message from your script.
Osvaldo.