-1

What is the best way to avoid this kind of attack on the mail server?

Mar 22 21:47:46 mail dovecot: imap-login: Disconnected (auth failed, 1 attempts in 9 secs): user=<andree_fontaine@mydomain>, method=PLAIN, rip=60.173.149.237, lip=172.16.16.1, TLS, session=<Ds/cmwpoCwA8rZXt> Mar 22 21:47:52 mail dovecot: imap-login: Disconnected (auth failed, 1 attempts in 9 secs): user=<camilla_blanc@mydomain>, method=PLAIN, rip=61.185.139.72, lip=172.16.16.1, TLS, session=<dsk9nApoggA9uYtI> Mar 22 21:53:41 mail dovecot: imap-login: Disconnected (auth failed, 1 attempts in 11 secs): user=<emerick_christianne@mydomain>, method=PLAIN, rip=122.117.63.83, lip=172.16.16.1, TLS: Disconnected, session=<eUvvsApoFAB6dT9T>

those ip addresses after rip= are from China

this is a fragment of /etc/postfix/main.cf:

myhostname = mail.mydomain
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = mail, localhost.localdomain, localhost<br>
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 192.168.0.0/24 172.16.16.0/24
mailbox_size_limit = 0

I have tried to solve the problem by capturing the ip address and adding it to the ip tables rules, but the intrusion continues with new ip addresses, all from China

cat /var/log/syslog |grep 'Disconnected (auth failed' |awk -F'=' '{print $4}' |sed 's/.\{5\}$//' |sort -u |awk '{print "$IPTABLES -I INPUT -s " $0 "/16 -j DROP"}'

the output of this command is like this

$IPTABLES -I INPUT -s 111.75.167.157/16 -j DROP
$IPTABLES -I INPUT -s 112.101.220.75/16 -j DROP
$IPTABLES -I INPUT -s 112.16.214.182/16 -j DROP
$IPTABLES -I INPUT -s 112.26.82.52/16 -j DROP
$IPTABLES -I INPUT -s 114.104.158.172/16 -j DROP
$IPTABLES -I INPUT -s 116.248.41.190/16 -j DROP
$IPTABLES -I INPUT -s 116.248.41.55/16 -j DROP
$IPTABLES -I INPUT -s 117.35.207.102/16 -j DROP
$IPTABLES -I INPUT -s 118.112.180.237/16 -j DROP

1 Answer 1

4

You can take your machine off the Internet, and that will stop the attacks. But it will also stop the mail coming in.

I suggest you use fail2ban to ban these bots, rather than trying to do it manually yourself. Recent versions of fail2ban already contain postfix and dovecot jails, which are disabled by default, so all you need to do is enable them. For instance, in a file included from /etc/fail2ban/jail.d/:

[postfix]
enabled = true

[dovecot]
enabled = true

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .