Postfix – block by sender email domain ip

postfix

For some time now I receive a lot of spam emails. The emails are all different but if I lookup the domain of the email address it always resolves to the same IP address.

So:

  • xyz@domain1.tld -> resolves to 80.249.161.131
  • ddfda@domain2.tld -> resolves to 80.249.161.131
  • etc.

In postfix I can reject each email address but in this case it is not helpful because the email address changes all the time.

The next problem I have is that each email is send through a different mail server. So I cannot block by sender address.

What I would like to do is block an email by the ip address. Not that of the sender but of the ip address of the domain used as part of the email.

Any suggestions on how this is done in postfix?

Best Answer

I believe this is what you are looking for: http://www.postfix.org/postconf.5.html#check_sender_a_access

Add

smtpd_sender_restrictions = check_sender_a_access hash:/etc/postfix/sender_a_access

in your main.cf

and add

80.249.161 REJECT

in your /etc/postfix/sender_a_access

and call

postmap /etc/postfix/sender_a_access

This will block the whole /24 subnet from that ip range where a lot of spam comes from.

I also use this for exactly the same ip range ;).

Related Topic