I am using Ubuntu 22.04 LTS and I am trying to prevent repeated connection attempts to our mail server using fail2ban. Fail2ban creates a proper entry in the iptables configuration, but the related IP address(es) can still connect.
When I look at the iptables configuration, it looks fine.
# iptables --list
Chain INPUT (policy ACCEPT)
target prot opt source destination
f2b-postfix-sasl tcp -- anywhere anywhere multiport dports smtp
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain f2b-postfix-sasl (1 references)
target prot opt source destination
REJECT all -- 80.94.95.184 anywhere reject-with icmp-port-unreachable
REJECT all -- 141.98.10.150 anywhere reject-with icmp-port-unreachable
RETURN all -- anywhere anywhere
But checking /var/log/mail.log I can see these IP addresses still are able to connect.
So fail2ban log looks like:
2023-06-30 09:47:54,108 fail2ban.actions [4183541]: NOTICE [postfix-sasl] Ban 80.94.95.184
2023-06-30 09:48:02,011 fail2ban.filter [4183541]: INFO [postfix-sasl] Found 141.98.10.150 - 2023-06-30 09:48:02
2023-06-30 09:48:02,128 fail2ban.actions [4183541]: WARNING [postfix-sasl] 141.98.10.150 already banned
2023-06-30 09:48:52,314 fail2ban.filter [4183541]: INFO [postfix-sasl] Found 141.98.10.150 - 2023-06-30 09:48:52
2023-06-30 09:49:40,343 fail2ban.filter [4183541]: INFO [postfix-sasl] Found 141.98.10.150 - 2023-06-30 09:49:40
2023-06-30 09:50:31,453 fail2ban.filter [4183541]: INFO [postfix-sasl] Found 141.98.10.150 - 2023-06-30 09:50:31
2023-06-30 09:50:31,511 fail2ban.actions [4183541]: WARNING [postfix-sasl] 141.98.10.150 already banned
As you can see, it keeps trying to ban the IP because for some reason the IP address can still connect to my machine.
Any advice would be greatly appreciated.