[CentOS] iptables - how to block established connections with fail2ban?

Thu Jun 27 07:51:54 UTC 2019
Roberto Ragusa <mail at robertoragusa.it>

On 6/26/19 8:41 AM, MRob wrote:
> I am working to a CentOS 6 server with nonstandard iptables system without rule for ACCEPT ESTABLISHED connections. All tables and chains empty (flush by legacy custom script) so only filter/INPUT chain has rules (also fail2ban chain):
> Chain INPUT (policy ACCEPT)
> target     prot opt source               destination
> f2b-postfix   tcp  --  
> Chain f2b-postfix (1 references)
> target     prot opt source               destination
> REJECT     all  --           reject-with icmp-port-unreachable
> REJECT     all  --           reject-with icmp-port-unreachable
> RETURN     all  --  
> When fail2ban block a IP address, established connections are allowed to continue, but with no rule to accept established connections how is that possible? Why doesn't f2b first rule block established connections?

The first rule should indeed block traffic for the established connections too.
It matches tcp only, are your connections really on tcp (and ipv4)?

Try adding the "-v" option to iptables so you can see the packet counters.
Do some experiments and check if the counters grow or not
when you expect packets to be dropped.


    Roberto Ragusa    mail at robertoragusa.it