Stopping spam with Postfix
I get a ridiculous amount of spam (500+ emails/day), most of which is caught by Spamassasin. However, this takes its toll on my poor virtual machine, which has most of its 250MB of RAM eaten up by MySQL as it is. As a result, I’ve started to be more aggressive with the rules I apply to incoming mail, which include:
- Reject anything from an invalid hostname.
- Reject emails where the sender address is a non-existant domain.
- Reject where the recipient address is a non-existant domain.
- Reject where the domain is hosted on this server but the email address is invalid (e.g. iveabigone@roguestudents.com).
- Check against Spamhaus RBL.
- Greylist.
Naturally, open relaying is disabled too. I’ve also updated the DNS for all of my domains so that they only have one MX record, as secondary servers are prone to abuse and can’t usually check whether an individual address is deliverable until they pass the message on to the primary server. Greylisting has proved to be particularly effective—personally I’m not a big fan of this solution as it introduces unnecessary delays, but the trade off between mail arriving a bit later and the amount of time I have to spend dealing with spam means that enabling it is now a no-brainer.
I could increase the level of checks by rejecting mail from servers without a reverse DNS record or which don’t identify themselves correctly in HELO/EHLO, but unfortunately that impacts too much on legitimate mail from people who can’t configure servers properly.
Since implementing these checks, my spam has fallen from 500 messages per day to about 10 per day, a reduction of 98%, even though my mail server is still receiving the same number of incoming connections. Furthermore, I’m no longer seeing “out of memory” error messages on my virtual machines, which is a great relief as this usually meant downtime until I noticed the problem, followed by a reboot.
Yes, I know I could just set my MX records to Google and let Gmail do all the work for me, but I don’t like the idea of a company in the US who I have absolutely no control over holding all of my emails and performing data mining on them.
[...] obvious security holes which needed plugging. Most services seemed secure, and I’d already cracked down on spam, but I did notice a lot of failed login attempts for ssh in the authentication log [...]
Securing ssh on Linux at Data Circle
1 Jan 10 at 12:58 pm