I run my own email server, and a friend received a compromised laptop from work which resulted in a spam attack from Russia yesterday. Turtle settings saved the days with thousands of emails still in the queue when I saw the problem, however it made me realize that everyone with accounts on my server are local, do not travel, and have no requirement to send emails from outside the country.

I found how to use the smtpd_discard_ehlo_keyword_address_maps setting in postfix to block a CIDR list of IPs, then found a maintained list of IPs by country codes on github. Cool so far, and a script to keep my local list updated was easy enough.

Now the question is, what countries should I be blocking? There are plenty of lists of the top hacking sources, but it’s hard to block #2 (the US) when that’s where I am located. But otherwise, does anyone have a list of countries they outright block from logging on to their servers? From the above google searches I have 17 countries blocked so far, and in the first 30 minutes already stopped login attempts from three of those countries, so it appears to be working.

Of course I could write a script to parse my logs to see who has already made attempts, but that’s what services like fail2ban are for, and I’m just wondering if there are any countries in particular I should directly block? My list so far includes the following: ae bg br cn de hk id in ir iq il kp ng ru sa th vn

The question itself may not be that interesting, but I thought at the very least some folks might be interested in my experience and think about doing something similar themselves. I can post more details of what I did if there is any interest.

  • SheeEttin@lemmy.world
    link
    fedilink
    English
    arrow-up
    4
    arrow-down
    1
    ·
    11 months ago

    no requirement to send emails from outside the country

    So all of them? Have them VPN if they eventually need to.

    Also, you’re using MFA, right? Right?

    • Shdwdrgn@mander.xyzOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      11 months ago

      Funny thing, I was actually looking into this earlier tonight and couldn’t find any info on how to implement MFA with postfix. I did find some discussions of limiting access to known IPs, but that requires manually tracking everyone’s logins. I’ll keep digging though, I’m sure I’ll find something.