I have an script that bans selected IPs from my server.
Example:
iptables -A INPUT -s 123.123.123.123 -j DROP
My question is: When this rule will start working?
I'm asking this, because yesterday I banned an IP, but it was still connected to my server... is something wrong with my command or something else?
Operations with
iptables
and theip6tables
(for IPv6) commands are applied immediately. You might have a rule in your INPUT chain which accepts the traffic before it reaches this one, like:If you apply your rule with
-A
, the rule will be appended after the previous rules and even if you say that traffic from 123.123.123.123 should be blocked, the rule allowing TCP 80 traffic has precedence. It's recommended that you insert a new chain (blocklist
below) in your ruleset as in:And then apply rules to the blocklist chain instead of the INPUT chain: